home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Games / PD / Imperium-ST / Source / IT_ST.p < prev    next >
Text File  |  2000-01-01  |  532KB  |  12,724 lines

  1. program StarFight;
  2.  
  3.  { 
  4.  * Copyright (C) Virtual Worlds Productions & Oxygenic
  5.  *  http://www.VirtualWorlds.de
  6.  *
  7.  *  IT 2 is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2, or (at your option)
  10.  *  any later version.
  11.  *   
  12.  *  IT 2 is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *   
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with GNU Make; see the file COPYING.  If not, write to
  19.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  20.  *
  21.  }
  22.  
  23.  
  24. USES Intuition,Graphics;
  25.  
  26. {$incl "intuition/intuitionbase.h","AGA.lib","libraries/dos.h",
  27.        "libraries/dosextens.h","libraries/diskfont.h","soundplay.mod",
  28.        "exec/memory.h","medplayer.lib"}
  29.  
  30. const FLAG_UNKNOWN=$0;
  31. const FLAG_KNOWN=$80;
  32. const FLAG_TERRA=20;
  33. const FLAG_KLEGAN=8;
  34. const FLAG_REMALO=96;
  35. const FLAG_CARDAC=10;
  36.  
  37. const FLAG_FERAGI=67;
  38. const FLAG_BAROJA=11;
  39. const FLAG_VOLKAN=27;
  40.  
  41. const FLAG_OTHER=1;
  42. const FLAG_MAQUES=12;
  43. const FLAG_CIV_MASK=(FLAG_TERRA  or FLAG_KLEGAN or FLAG_REMALO or FLAG_CARDAC
  44.                   or FLAG_FERAGI or FLAG_BAROJA or FLAG_VOLKAN or FLAG_OTHER
  45.                   or FLAG_MAQUES);
  46. const WFLAG_CEBORC=2;
  47. const WFLAG_DCON=3;
  48. const WFLAG_FIELD=4;
  49. const WFLAG_JAHADR=5;
  50.  
  51.  
  52. MASK_LTRUPPS=$0F;
  53. MASK_SIEDLER=$F0;
  54.  
  55. const RDELAY=1;
  56. const LOGOSIZE=14500;
  57.  
  58. const PAUSE=85;
  59. const GFLAG_EXPLORE=1;
  60. const GFLAG_ATTACK=2;
  61.  
  62. const SHIPFLAG_NONE=0;
  63. const SHIPFLAG_WATER=1;
  64.  
  65. const LEVEL_DIED=0;
  66. const LEVEL_UNKNOWN=1;
  67. const LEVEL_PEACE=2;
  68. const LEVEL_WAR=3;
  69. const LEVEL_ALLIANZ=4;
  70. const LEVEL_NO_ALLIANZ=5;
  71. const LEVEL_COLDWAR=6;
  72.  
  73. const TYPE_PLANET=2;
  74. const TYPE_SHIP=4;
  75. const TYPE_STARGATE=16;
  76. const TYPE_WORMHOLE=32;
  77.  
  78. const SHIPTYPE_FLEET=200;
  79.  
  80. const CLASS_DESERT=   5;  {D};
  81. const CLASS_HALFEARTH=4;  {H};
  82. const CLASS_EARTH=    6;  {M};
  83. const CLASS_SATURN=   3;  {S};
  84. const CLASS_GAS=      1;  {G};
  85. const CLASS_ICE=      8;  {I};
  86. const CLASS_PHANTOM=  7;  {P};
  87. const CLASS_STONES=   0;  {T};
  88. const CLASS_WATER=    2;  {W};
  89.  
  90. const WEAPON_GUN=1;
  91. const WEAPON_LASER=3;
  92. const WEAPON_PHASER=5;
  93. const WEAPON_DISRUPTOR=7;
  94. const WEAPON_PTORPEDO=9;
  95.  
  96. const MODE_REFRESH = 0;
  97. const MODE_REDRAW  = 1;
  98. const MODE_FLEET   = 2;
  99. const MODE_STARGATE= 3;
  100. const MODE_ONCE    = 4;
  101. const MODE_ALL     = 5;
  102. const MODE_OFFENSIV= 8;
  103. const MODE_DEFENSIV= 9;
  104. const MODE_SHIPS   =10;
  105. const MODE_TERRITORIUM=11;
  106. const MODE_BELEIDIGUNG=12;
  107. const MODE_MONEY   =13;
  108. const MODE_FORCE   =14;
  109.  
  110. const STATE_ALL_OCC=1;
  111. const STATE_ENEMY=2;
  112. const STATE_TACTICAL=3;
  113.  
  114. const SCREEN_PLANET=1;
  115. const SCREEN_INVENTION=2;
  116. const SCREEN_HISCORE=3;
  117. const SCREEN_TECH=4;
  118.  
  119. const TARGET_POSITION=127;
  120. const TARGET_STARGATE=26;
  121. const TARGET_ENEMY_SHIP=126;
  122.  
  123. const INFLATION=1.03;
  124. const MODULES=4;
  125. const MAXSYSTEMS=25;
  126. const MAXMAQUES=5;
  127. const MAXHOLES=3;
  128. const SOUNDS=4;
  129. const CACHES=4;
  130. const IMAGES=2;
  131. const GADGETS=3;
  132. const FONTS=5;
  133. const MAXPLANETS=11;
  134. const MAXCIVS=9;
  135. const PATHS=11;
  136. const MAXPMONEY=102000;
  137.  
  138. type TagArr=array [1..14] of long;
  139. type PenArr=array [1..13] of word;
  140. type ColSpecArr=array [1..5] of integer;
  141. type StrArr=array [1..MAXSYSTEMS] of string[11];
  142. type StrArr42=array [1..42] of string[30];
  143. type ByteArr42=array [0..42] of byte;
  144. type ByteArr22=array [1..22] of byte;
  145. type LongArr42=array [0..42] of long;
  146. type StrArrMAXPLANETS=array [1..MAXPLANETS] of string[5];
  147. type StrArr11=array [1..11] of string[15];
  148. type WordArr32=array[1..34] of word;
  149.  
  150.  
  151. type ShipHeader=^r_ShipHeader;
  152. type r_ShipHeader=record;               { Frei verkettete Strukturen }
  153.         Age,SType,Owner,Flags,ShieldBonus,Ladung,Fracht :byte;
  154.         PosX,PosY                                       :short;
  155.         Shield,Weapon,Repair                            :byte;
  156.         Moving,Source,Target,Tactical                   :short;
  157.         TargetShip,BeforeShip,NextShip                  :ShipHeader;
  158.      end;
  159. type r_ShipData=record
  160.         MaxLoad,MaxShield,MaxMove,WeaponPower  :byte;
  161.      end;
  162. type r_SystemHeader=record
  163.         PlanetMemA                              :long;
  164.         State                                   :byte;
  165.         FirstShip                               :r_ShipHeader;
  166.         Planets,vNS,SysOwner                    :byte;
  167.      end;
  168. type PlanetHeader=^r_PlanetHeader;
  169. type r_PlanetHeader=record
  170.         Class,Size,PFlags,Ethno                                 :byte;
  171.         PName                                                   :string[16];
  172.         PosX,PosY                                               :real;
  173.         Population,Water                                        :long;
  174.         Biosphäre,Infrastruktur,Industrie                       :byte
  175.         XProjectCosts,XProjectPayed                             :long;
  176.         ProjectID                                               :short
  177.         FirstShip                                               :r_ShipHeader;
  178.         ProjectPtr                                              :^ByteArr42;
  179.      end;
  180. type r_HiScore=record
  181.         Player          :array [1..8] of string[20]
  182.         CivVar          :array [1..8] of byte;
  183.         Points          :array [1..8] of long;
  184.      end;
  185. type r_Key=record
  186.         Time                    :long;
  187.         Name                    :string[50];
  188.         ID                      :long;
  189.         Street                  :string[50];
  190.         Number                  :long;
  191.         City                    :string[50];
  192.      end;
  193. type ITBitMap=record
  194.         BytesPerRow,Rows        :word;
  195.         Flags,Depth             :byte;
  196.         pad                     :word;
  197.         PPtr0,PPtr1,PPtr2,PPtr3,
  198.         PPtr4,PPtr5,PPtr6,PPTr7 :PLANEPTR;
  199.         MemA,MemL               :long;
  200.      end;
  201. type r_WormHole=record
  202.         System                  :array [1..2] of byte;
  203.         PosX,PosY               :array [1..2] of short;
  204.         CivKnowledge            :array [1..MAXCIVS] of byte;
  205.      end;
  206.  
  207. var Key         :r_Key;
  208.  
  209. var Tags        :TagArr;
  210. var Pens        :PenArr;
  211. var ColSpec     :ColSpecArr;
  212.  
  213. var NeuScreen                           :NewScreen;
  214. var MyScreen                            :array [1..2] of ^Screen;
  215. var NeuWindow                           :NewWindow;
  216. var MyWindow                            :array [1..2] of ^Window;
  217. var XScreen                             :^Screen;
  218. var ImgBitMap4,ImgBitMap7,ImgBitMap8    :ITBitMap;
  219. var Img,GadImg1,GadImg2                 :Image;
  220. var CustomTA                            :array [1..FONTS] of TextAttr;
  221. var CustomFont                          :array [1..FONTS] of ^TextFont;
  222. var IBase                               :^IntuitionBase;
  223. var IMsg                                :^IntuiMessage;
  224.  
  225. var Process_Ptr                         :p_Process;
  226. var OldWindow_Ptr                       :ptr;
  227.  
  228. var MyWormHole                          :array [1..MAXHOLES] of r_WormHole;
  229. var Romanum                             :StrArrMAXPLANETS;
  230. var PNames                              :array [0..MAXCIVS-2] of StrArr11;
  231. var SystemX,SystemY                     :array [1..MAXSYSTEMS] of integer;
  232. var SystemFlags                         :array [1..MAXCIVS,1..MAXSYSTEMS] of byte;
  233. var SystemHeader                        :array [1..MAXSYSTEMS] of r_SystemHeader;
  234. var Technology,Project                  :StrArr42;
  235. var TechUse1,TechUse2,ProjectNeedsTech,
  236.     ProjectNeedsProject                 :ByteArr42;
  237. var PriorityList                        :ByteArr22;
  238.  
  239. var SoundMemA                           :array [1..SOUNDS] of long;
  240. var SoundSize                           :array [1..SOUNDS] of word;
  241. var CacheMemA,CacheMemL                 :array [1..CACHES] of long;
  242. var LogoMemA,LogoSMemA,LogoSMemL        :array [0..MAXCIVS-2] of long;
  243. var ZeroSound                           :long;
  244. var IMemA,IMemL                         :array [0..IMAGES] of long;
  245. var ModMemA,ModMemL                     :array [1..MODULES] of long;
  246. var DKnopf                              :array [1..GADGETS] of Gadget;
  247. var DKnopfTx                            :array [1..GADGETS] of IntuiText;
  248. var PathStr                             :array [1..PATHS] of str;
  249. var ShipData                            :array [8..27] of r_ShipData;
  250.  
  251. var AllCreative,Militärausgaben,Verschrottung   :array [1..MAXCIVS] of long;
  252. var LastDisplay,Warnung                         :array [1..MAXCIVS] of byte;
  253. var PathMemA,PathMemL,HelpID,Year,TMPtr,l1,l2,
  254.     MaquesShips                                 :long;
  255. var OffsetX,OffsetY,OldX,OldY                   :integer;
  256. var FHandle                                     :BPTR;
  257. var RData                                       :^word;
  258. var LData                                       :^byte;
  259. var Screen2,ObjType,LastSystem,Level,b,
  260.     RawCode,ActPlayer,ActPlayerFlag,LastPlayer,
  261.     Display,HomePlanets,NewPNames               :byte;
  262. var ObjPtr,MTBase,MDBBase                       :ptr;
  263. var s,s2                                        :string;
  264. var WBench,Bool,Valid,IMemID,DoClock,
  265.     MultiPlayer,Informed                        :boolean;
  266. var HiScore                                     :r_HiScore;
  267. var GetPlanet                                   :array [1..MAXCIVS] of ^r_PlanetHeader;
  268. var GetPlanetSys                                :array [1..MAXCIVS] of byte;
  269. var vNSonde                                     :array [1..MAXCIVS] of boolean;
  270. var i,j                                         :integer;
  271.  
  272. type r_Save=record
  273.        WarState,LastWarState                            :array [1..MAXCIVS,1..MAXCIVS] of byte;
  274.        Staatstopf,Bevölkerung,WarPower,MaxWarPower,
  275.        ImperatorState                                   :array [1..MAXCIVS] of long;
  276.        SSMoney                                          :array [1..MAXCIVS,1..MAXCIVS] of long;
  277.        TechCosts,ProjectCosts                           :array [1..MAXCIVS] of LongArr42;
  278.        ActTech,GlobalFlags,GSteuer,JSteuer              :array [1..MAXCIVS] of byte;
  279.        stProject,SService,Military                      :array [1..MAXCIVS] of byte;
  280.        PlayMySelf,SmallFight,SmallLand,FastMove,NoWorm  :boolean;
  281.        WorldFlag,SYSTEMS,CivilWar                       :byte
  282.        SystemName                                       :StrArr;
  283.        CivPlayer                                        :array [1..MAXCIVS] of byte;
  284. end;
  285.  
  286. var Save                :r_Save;
  287.  
  288.  
  289.  
  290. function GETCIVFLAG(CivVar :byte):byte;
  291.  
  292. begin
  293.    case CivVar of
  294.        1: GETCIVFLAG:=FLAG_TERRA;
  295.        2: GETCIVFLAG:=FLAG_KLEGAN;
  296.        3: GETCIVFLAG:=FLAG_REMALO;
  297.        4: GETCIVFLAG:=FLAG_CARDAC;
  298.        5: GETCIVFLAG:=FLAG_FERAGI;
  299.        6: GETCIVFLAG:=FLAG_BAROJA;
  300.        7: GETCIVFLAG:=FLAG_VOLKAN;
  301.        8: GETCIVFLAG:=FLAG_OTHER;
  302.        9: GETCIVFLAG:=FLAG_MAQUES;
  303.        otherwise GETCIVFLAG:=0;
  304.    end;
  305. end;
  306.  
  307.  
  308.  
  309. procedure REMOVEPLAYER(ActPlayer :byte);
  310.  
  311. var MyPlanetHeader              :^r_PlanetHeader;
  312. var MyShipPtr,ActShipPtr        :^r_ShipHeader;
  313. var i,j,ActPlayerFlag           :byte;
  314.  
  315. begin
  316.    Save.Bevölkerung[ActPlayer]:=0;
  317.    ActPlayerFlag:=GETCIVFLAG(ActPlayer);
  318.    for i:=1 to MAXSYSTEMS do with SystemHeader[i] do if PlanetMemA>0 then begin
  319.       for j:=1 to SystemHeader[i].Planets do begin
  320.          MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  321.          if MyPlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag then
  322.           with MyPlanetHeader^ do begin
  323.             PFlags:=0;        Ethno:=0;
  324.             Population:=0;
  325.             XProjectCosts:=0; XProjectPayed:=0;
  326.             ProjectID:=0;
  327.             if ProjectPtr<>NIL then begin
  328.                ProjectPtr^[7]:=0;
  329.                ProjectPtr^[26]:=0;
  330.                ProjectPtr^[27]:=0;
  331.             end;
  332.          end;
  333.          if MyPlanetHeader^.FirstShip.NextShip<>NIL then begin
  334.             MyShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  335.             repeat
  336.                if MyShipPtr^.Owner=ActPlayerFlag then MyShipPtr^.Owner:=0;
  337.                MyShipPtr:=MyShipPtr^.NextShip;
  338.             until MyShipPtr=NIL;
  339.          end;
  340.       end;
  341.       if SystemHeader[i].FirstShip.NextShip<>NIL then begin
  342.          MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  343.          repeat
  344.             if MyShipPtr^.Owner=ActPlayerFlag then MyShipPtr^.Owner:=0;
  345.             if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  346.                ActShipPtr:=MyShipPtr^.TargetShip;
  347.                repeat
  348.                   if ActShipPtr^.Owner=ActPlayerFlag then ActShipPtr^.Owner:=0;
  349.                   ActShipPtr:=ActShipPtr^.NextShip;
  350.                until ActShipPtr=NIL;
  351.             end;
  352.             MyShipPtr:=MyShipPtr^.NextShip;
  353.          until MyShipPtr=NIL;
  354.       end;
  355.    end;
  356. end;
  357.  
  358.  
  359.  
  360. procedure INITVARS;
  361.  
  362. var i,j :integer;
  363.  
  364. begin
  365.    s:='Hey CRACKER! Do you want to kill the AMIGA? Then you should continue with fucking off the rest of available AMIGA-Software and demoralizing the rest of AMIGA-Coders!';
  366.    s:='But how about doing more CONSTRUCTIVE things? You could program your OWN GAME! Or are you too stupid???';
  367.    s:='Yes, you need some BRAIN, IDEAS, KNOWHOW and CLEVERNESS for such a project! And I dont´t know if you have it if you do only such lame things!';
  368.    TMPtr:=0;
  369.    Pens:=PenArr(0,0,0,0,0,0,0,0,0,0,0,0,0);
  370.    for i:=1 to SOUNDS do SoundMemA[i]:=0;
  371.    for i:=0 to IMAGES do IMemA[i]:=0;
  372.    for i:=1 to MODULES do ModMemA[i]:=0;
  373.    for i:=1 to CACHES do CacheMemA[i]:=0;
  374.    ImgBitMap4:=ITBitMap(0,0,0,0,0,NIL,NIL,NIL,NIL,NIL,NIL,NIL,NIL,0,0);
  375.    ImgBitMap7:=ITBitMap(0,0,0,0,0,NIL,NIL,NIL,NIL,NIL,NIL,NIL,NIL,0,0);
  376.    ImgBitMap8:=ITBitMap(0,0,0,0,0,NIL,NIL,NIL,NIL,NIL,NIL,NIL,NIL,0,0);
  377.    MyScreen[1]:=NIL; MyScreen[2]:=NIL;
  378.    Screen2:=0;       PathMemA:=0;     ZeroSound:=0;
  379.    Year:=1899;       Level:=5;        Display:=100;
  380.    ActPlayer:=1;     ActPlayerFlag:=FLAG_TERRA;
  381.    LastPlayer:=0;    HomePlanets:=1;  MaquesShips:=0;
  382.    Valid:=true;      IMemID:=false;   DoClock:=false;
  383.    Save.PlayMySelf:=false; Save.NoWorm:=false;
  384.    Save.SmallLand:=false;  Save.SmallFight:=false;
  385.    Save.FastMove:=false;   Save.WorldFlag:=0;
  386.    Save.CivPlayer[1]:=1;   for i:=2 to MAXCIVS do Save.CivPlayer[i]:=0;
  387.    Save.CivilWar:=0;
  388.  
  389.    Save.SystemName:=StrArr('Sonne',    'Centauri','Wega',      'Rigel',    'Cassiopeia',
  390.                            'Deneb',    'Castor',  'Regulus',   'Sirius',   'Spica',
  391.                            'Aldebaran','Arktur',  'Beteigeuze','Kapella',  'Kepheus',
  392.                            'Canopus',  'Mira',    'Antares',   'Achernar', 'Atair',
  393.                            'Prokyon',  'Pollux',  'Algol',     'Fomalhaut','Altar');
  394.    Technology:=StrArr42('Halbleiter',              'Informatik',
  395.                         'Recycling',               'Kernfusion',
  396.                         'Carbonfasern',            'Keramik-Technologie',
  397.                         'Mikroelektronik',         'Fotovoltaik',
  398.                         'Gentechnik',              'Teilchenphysik',
  399.                         'Raumstations-Technologie','Supraleiter',
  400.                         'Mikrocomputer',           'selbstwachsende Strukturen',
  401.                         'Hochenergie-Laser',       'Raumdock-Technologie',
  402.                         'Triravit',                'Cyberspace',
  403.                         'Bio-Elektronik',          'Ionenantrieb',
  404.                         'Duravit',                 'künstliche Intelligenz',
  405.                         'Bio-Computer',            'Phaser',
  406.                         'Duranium',                'Androiden',
  407.                         'Raumholografie',          'Impulsantrieb',
  408.                         'Materiedestruktion',      'Sol-Antrieb',
  409.                         'Beamen',                  'Disruptoren',
  410.                         'Warp-Antrieb',            'selbstorganisierende Systeme',
  411.                         'Tiefschlaf-Technologie',  'Transwarp',
  412.                         'Protonentorpedos',        'Bewußtseins-Transformation',
  413.                         'Chaostheorie',            'Energiestrukturen',
  414.                         'Weltformel',              'energetische Intelligenz');
  415.    TechUse1:=ByteArr42(0,  0,0,0,0,0,  0,1,1,3,4,  3,6,2,8,10,   4,11,13,13,15, 16,18,19,20,21,  12,23,24,24,21,  27,29,25, 2,26,  31,32,34,13,36,  39,38);
  416.    TechUse2:=ByteArr42(0,  0,0,0,0,0,  0,1,1,3,4,  5,6,7,9,16,  11,12,13,14,17, 20,18,22,20,30,  22,23,24,24,28,  29,33,30,31,31,  32,33,35,13,37,  40,41);
  417.    Save.TechCosts[1]:=LongArr42(0,
  418.                             2010,  2510, 3020,13020, 3030, 4530, 4040,  5040, 6550, 7050,
  419.                             7060,  9560,11070,11070,12580,13080,15090, 15100,16100,17100,
  420.                            18200, 29200,21300,21800,22900,23400,24500, 26000,26600,27600,
  421.                            29200, 30200,33300,33800,35400,38900,40500, 55000,15000,55000,
  422.                            85000,135000);
  423.    Project:=StrArr42('BIOSPHERE II',   'FÖDERATION DER PLANETEN','KREBSHEILUNG',
  424.                 {4}  'PANDORA-Projekt','BIG-BANG-Projekt',       'GENESIS-Projekt',
  425.                 {7}  'Q-Projekt',
  426.  
  427.                 {8}  'Wostok',      'Mir',      'Spaceshuttle','Starwing',
  428.                {12}  'Galaxy',      'Catamaran','Quasar',      'Destroyer',
  429.                {16}  'Enterprise A','Deltawing','Tristars',    'Enterprise B',
  430.                {20}  'Warbird',     'Stargate', 'Enterprise C','Cruiser',
  431.                {24}  'Starburner',
  432.  
  433.                {25}  'Raumdock','Siedler-Einheit','Landungstruppen','Kontinentale Union',
  434.  
  435.                {29}  'Globale Union',      'Recycling-Anlage',     'Fusions-Kraftwerk',
  436.                {32}  'Hydrolyse-Kraftwerk','Teilchenbeschleuniger','SDI',
  437.                {35}  'Internet',           'virtuelle Universität','intelligente Fabrik',
  438.                {38}  'Informationhighway', 'von-Neumann-Sonde',    'Spacephalanx',
  439.                {41}  'Microiden',          'Wetter-Station');
  440.    PriorityList:=ByteArr22(25, 5,1,34, 40,30,6,37, 7,31,41,33, 32,36,42,35,38,28,29,3,4,39);
  441.    ProjectNeedsTech:=ByteArr42(0,
  442.                                0,0,9,19,40,41,42,
  443.                                7,11,15,16, 20,21,24,28, 30,25,33,32, 35,31,36,37, 38,
  444.                                16,0,0,0,
  445.                                2,3,4,8,10,12,13,18,22,23,26,29,34,39);
  446.    ProjectNeedsProject:=ByteArr42(0,
  447.                                   0,29,0,3,0,0,6,
  448.                                   0,0,0,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
  449.                                   0,1,0,0,
  450.                                   28,0,32,0,0,0,0,0,0,35,0,34,0,0);
  451.    Save.ProjectCosts[1]:=LongArr42(0,
  452.                                  92010, 184020, 276030,
  453.                                 368040, 561050, 664060,
  454.                                 795000,
  455.  
  456.                               15080,17090,22100,25110,
  457.                               28120,31130,34140,37150,
  458.                               39160,43170,49180,55190,
  459.                               63200,70210,78220,86230,
  460.                               96240,
  461.  
  462.                                45250,12260,17270,45280,
  463.  
  464.                                50290, 19300, 55310,
  465.                                35320, 50330, 55340,
  466.                                30350, 25360, 25370,
  467.                                50380, 35390,130400,
  468.                                70410, 80420);
  469.    for i:=1 to MAXCIVS do with Save do begin
  470.       GetPlanet[i]:=NIL;               GetPlanetSys[i]:=0;
  471.       Verschrottung[i]:=0;             vNSonde[i]:=false;
  472.       Warnung[i]:=0;
  473.       GlobalFlags[i]:=GFLAG_EXPLORE;   MaxWarPower[i]:=0;
  474.       SService[i]:=0;                  Military[i]:=0;
  475.       TechCosts[i]:=Save.TechCosts[1]; ProjectCosts[i]:=Save.ProjectCosts[1];
  476.       ImperatorState[i]:=2500;         Staatstopf[i]:=0;
  477.       Bevölkerung[i]:=5;               WarPower[i]:=0;
  478.       AllCreative[i]:=1;               ActTech[i]:=0;
  479.       GSteuer[i]:=10;                  JSteuer[i]:=0;
  480.       stProject[i]:=0;
  481.    end;
  482.    for i:=0 to (MAXCIVS-2) do with Save do begin
  483.       LogoMemA[i]:=0;
  484.       LogoSMemA[i]:=0;
  485.       LogoSMemL[i]:=0;
  486.    end;
  487.    for i:=1 to MAXCIVS do for j:=1 to MAXCIVS do Save.SSMoney[i,j]:=0;
  488.  
  489.    for i:=1 to MAXCIVS do for j:=1 to MAXCIVS do begin
  490.       LastDisplay[i]:=0;
  491.       Militärausgaben[i]:=0;
  492.       Save.WarState[i,j]:=LEVEL_UNKNOWN;     Save.WarState[j,i]:=LEVEL_UNKNOWN;
  493.       Save.LastWarState[i,j]:=LEVEL_UNKNOWN; Save.LastWarState[j,i]:=LEVEL_UNKNOWN;
  494.       Save.WarState[j,8]:=LEVEL_DIED;        Save.WarState[j,9]:=LEVEL_DIED;
  495.    end;
  496.    Save.WarState[1,1]:=LEVEL_PEACE;
  497.    Save.SYSTEMS:=MAXSYSTEMS;
  498.    for i:=1 to MAXSYSTEMS do SystemHeader[i].PlanetMemA:=0;
  499.  
  500.               {ShipData:    MaxLoad,MaxShield,MaxMove,WeaponPower}
  501.    ShipData[8]:= r_ShipData( 3,  7, 1, 1);   {Wostok,       7}
  502.    ShipData[9]:= r_ShipData( 4,  5, 1, 1);   {Mir,         11}
  503.    ShipData[10]:=r_ShipData( 5, 16, 2, 5);   {Spaceshuttle,15}
  504.    ShipData[11]:=r_ShipData( 6, 22, 3, 4);   {Starwing,    16}
  505.    ShipData[12]:=r_ShipData( 9, 36, 6, 5);   {Galaxy,      20}
  506.    ShipData[13]:=r_ShipData(10, 49, 6, 6);   {Catamaran,   24}
  507.    ShipData[14]:=r_ShipData(11, 57, 8, 7);   {Quasar,      21}
  508.    ShipData[15]:=r_ShipData( 9, 64, 7, 9);   {Destroyer    28}
  509.    ShipData[16]:=r_ShipData(10, 79,12,10);   {Enterprise A,25}
  510.    ShipData[17]:=r_ShipData(15, 93,10,11);   {Delta-Wing,  30}
  511.    ShipData[18]:=r_ShipData( 9,107,16,12);   {Tristars,    33}
  512.    ShipData[19]:=r_ShipData(19,121,14,14);   {Enterprise B,32}
  513.    ShipData[20]:=r_ShipData(22,129,21,15);   {Warbird,     35}
  514.    ShipData[21]:=r_ShipData( 4, 60,20,12);   {Stargate,    31}
  515.    ShipData[22]:=r_ShipData(25,136,19,16);   {Enterprise C,38}
  516.    ShipData[23]:=r_ShipData(28,149,27,18);   {Cruiser,     37}
  517.    ShipData[24]:=r_ShipData(33,160,24,20);   {Starburner,  36}
  518.    ShipData[27]:=r_ShipData(28,190,27,30);   {Borgschiff     }
  519.    { Maximal:               --,---,27,-                      }
  520.    Romanum:=StrArrMAXPLANETS('I','II','III','IV','V','VI','VII','VIII','IX','X','XI');
  521.    PNames[0]:=StrArr11('Talos','Scalos','Iconia','Odon','Genesis','Rosod',
  522.                        'Munaxx','Tzenketi','Yamos','Jake','Andmun');
  523.    PNames[1]:=StrArr11('Merkur','Venus', 'Erde',  'Mars','Jupiter',
  524.                        'Saturn','Uranus','Neptun','Pluto','','');
  525.    PNames[2]:=StrArr11('Darukis','Akaneb', 'Cronos','Sedokub','Praxis',
  526.                        'Dasekab','Khitomer','Vedekab', 'Damakeb','Khetamar',
  527.                        'Zhalakab');
  528.    PNames[3]:=StrArr11('Akusum', 'Celadum','Romulus','Dianum','Ecanum',
  529.                        'Jamaris','Lorius', 'Noratum','Tamarus','Pekateg',
  530.                        'Raletis');
  531.    PNames[4]:=StrArr11('Inarett',  'Ferraccud','Kardassia','Latecca',  'Ooro',
  532.                        'Reedameec','Soorov',   'Zalee',    'Zaalasena','Veda',
  533.                        'Sodoora');
  534.    PNames[5]:=StrArr11('Deragi',  'Sodaki',  'Ferengi Nar','Zolati', 'Plauti',
  535.                        'Olsatebi','Munakati','Rastoki',    'Mosavli','Berali',
  536.                        'Dresadai');
  537.    PNames[6]:=StrArr11('Bos','Dak','Bajor','Zeda','Co',
  538.                        'Zud','Fec','Paq', 'Loa', 'Zate',
  539.                        'Wid');
  540.    PNames[7]:=StrArr11('Wolaron','Unareus', 'Vulkan','Ataneia','Peratham',
  541.                        'Musacem','Geratios','Paluae','Idakel', 'Amirima',
  542.                        'Ressan');
  543.    NewPNames:=succ(random(MAXPLANETS));
  544.    OffsetX:=0; OffsetY:=0; OldX:=0; OldY:=0; LastSystem:=1;
  545. end;
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552. procedure SWITCHDISPLAY;
  553.  
  554. var pw  :^word;
  555.  
  556. begin
  557.    pw:=ptr(14676118);
  558.    pw^:=256;
  559. end;
  560.  
  561.  
  562.  
  563. procedure CLOSEMYSCREENS;
  564.  
  565. var i   :byte;
  566.  
  567. begin
  568.    ScreenToFront(XScreen);
  569.    SWITCHDISPLAY;
  570.    for i:=1 to 2 do if MyScreen[i]<>NIL then begin
  571.       while MyScreen[i]^.FirstWindow<>NIL do CloseWindow(MyScreen[i]^.FirstWindow);
  572.       CloseScreen(MyScreen[i]); MyScreen[i]:=NIL;
  573.    end;
  574. end;
  575.  
  576.  
  577.  
  578. procedure WRITE(IPosX,IPosY :word; Color,DMode :byte; XScreen :Screen; TA :byte; WText :str);
  579.  
  580. var MyText      :IntuiText;
  581.  
  582. begin
  583.    MyText:=IntuiText(Color,0,DMode and $F,IPosX,IPosY,^CustomTA[TA],WText,NIL);
  584.    if (DMode and 16=16) then MyText.LeftEdge:=IPosX-(IntuiTextLength(^MyText) div 2);
  585.    if (DMode and 32=32) then MyText.LeftEdge:=IPosX-IntuiTextLength(^MyText)-(CustomTA[TA].ta_YSize div 2);
  586.    if (DMode and 64=64) then begin
  587.       MyText.FrontPen:=0;
  588.       PrintIText(^XScreen.RastPort,^MyText,1,1);
  589.       MyText.FrontPen:=Color;
  590.    end;
  591.    PrintIText(^XScreen.RastPort,^MyText,0,0);
  592. end;
  593.  
  594.  
  595.  
  596. procedure PLAYSOUND(SID :byte; SRate :word);
  597.  
  598. var Vol         :byte;
  599.  
  600. begin
  601.    if TMPtr=0 then DMACON_WRITE^:=$0003;
  602.    WaitTOF;
  603.    if SID=1 then begin
  604.       if TMPtr=0 then begin
  605.          Vol:=IBase^.MouseX div 10;   SPVolB^:=Vol;   SPVolA^:=64-Vol;
  606.          SPAddrA^:=SoundMemA[SID]; SPFreqA^:=SRate; SPLengthA^:=SoundSize[SID];
  607.          SPAddrB^:=SoundMemA[SID]; SPFreqB^:=SRate; SPLengthB^:=SoundSize[SID];
  608.          DMACON_WRITE^:=$8003;
  609.          WaitTOF;
  610.          SPAddrA^:=ZeroSound; SPLengthA^:=1;
  611.          SPAddrB^:=ZeroSound; SPLengthB^:=1;
  612.       end;
  613.       repeat
  614.          delay(RDELAY);
  615.       until not (LData^ and 64=0) and not (RData^ and 1024=0) or Save.PlayMySelf;
  616.       if (TMPtr=0) and (SID=1) then begin
  617.          WaitTOF;
  618.          DMACON_WRITE^:=$0003;
  619.          WaitTOF;
  620.       end;
  621.    end else begin
  622.       SPAddrA^:=SoundMemA[SID];                SPVolA^:=64; SPFreqA^:=SRate; SPLengthA^:=SoundSize[SID] div 2;
  623.       SPAddrB^:=SoundMemA[SID]+SoundSize[SID]; SPVolB^:=64; SPFreqB^:=SRate; SPLengthB^:=SoundSize[SID] div 2;
  624.       if SID=4 then begin
  625.          SPAddrA^:=SoundMemA[SID]; SPVolA^:=64; SPFreqA^:=SRate; SPLengthA^:=SoundSize[SID];
  626.          SPAddrB^:=SoundMemA[SID]; SPVolB^:=64; SPFreqB^:=SRate; SPLengthB^:=SoundSize[SID];
  627.       end;
  628.       DMACON_WRITE^:=$8003;
  629.       WaitTOF;
  630.       SPAddrA^:=ZeroSound; SPLengthA^:=1;
  631.       SPAddrB^:=ZeroSound; SPLengthB^:=1;
  632.    end;
  633. end;
  634.  
  635.  
  636.  
  637. procedure CLEARINTUITION;
  638.  
  639. var i   :byte;
  640.  
  641. begin
  642.    if (MyScreen[1]^.FirstWindow=NIL) or (MyScreen[2]^.FirstWindow=NIL) then exit;
  643.    for i:=1 to 2 do repeat
  644.       RawCode:=0;
  645.       IMsg:=Get_Msg(MyWindow[i]^.UserPort);
  646.       if IMsg<>NIL then begin
  647.          RawCode:=1;
  648.          Reply_Msg(IMsg);
  649.       end;
  650.    until Rawcode=0;
  651. end;
  652.  
  653.  
  654.  
  655. function GETRAWCODE:byte;
  656.  
  657. begin
  658.    GETRAWCODE:=0;
  659.    if (MyScreen[1]^.FirstWindow=NIL) or (MyScreen[2]^.FirstWindow=NIL) then exit;
  660.    IMsg:=Get_Msg(MyWindow[1]^.UserPort);
  661.    if IMsg=NIL then IMsg:=Get_Msg(MyWindow[2]^.UserPort);
  662.    if IMsg<>NIL then begin
  663.       if IMsg^.Class=RAWKEY then GETRAWCODE:=IMsg^.Code;
  664.       Reply_Msg(IMsg);
  665.    end;
  666. end;
  667.  
  668.  
  669.  
  670. procedure WAITLOOP(Bool :boolean);
  671.  
  672. var i   :byte;
  673.  
  674. begin
  675.    repeat
  676.       delay(RDELAY);
  677.       RawCode:=GETRAWCODE;
  678.    until (RawCode in [64,67,68])
  679.    or (LData^ and 64=0) or (RData^ and 1024=0) or Bool;
  680.    PLAYSOUND(1,300);
  681.    repeat
  682.       delay(RDELAY);
  683.    until (not (LData^ and 64=0) and not (RData^ and 1024=0)) or Bool;
  684.    CLEARINTUITION;
  685. end;
  686.  
  687.  
  688.  
  689. procedure DECODE;
  690. forward;
  691.  
  692.  
  693.  
  694. function OPENSMOOTH(FStr :str; FMode :long):BPTR;
  695.  
  696. var FName       :string[100];
  697. var DName       :string[20];
  698. var FHandle     :BPTR;
  699. var i           :byte;
  700. var b           :boolean;
  701. var XScreen     :^Screen;
  702.  
  703. begin
  704.    FName:=FStr;
  705.    FHandle:=DosOpen(FName,FMode);
  706.    if FHandle=0 then begin
  707.       repeat
  708.          delay(RDELAY);
  709.       until not (LData^ and 64=0);
  710.       b:=false;
  711.       for i:=1 to length(FName) do if FName[i]=':' then begin
  712.          DName:=FName;
  713.          DName[i]:=chr(0);
  714.          b:=true;
  715.       end;
  716.       if b then begin
  717.          NeuScreen:=NewScreen(180,0,280,40,1,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,
  718.                               NIL,'',NIL,NIL);
  719.          Tags:=TagArr(SA_DisplayID,   ($9004+HelpID),
  720.                       SA_Interleaved, _TRUE,
  721.                       SA_DRAGGABLE,   _FALSE,
  722.                       SA_PENS,        addr(Pens),
  723.                       SA_COLORS,      addr(ColSpec),
  724.                       TAG_DONE,       0,0,0);
  725.          XScreen:=OpenScreenTagList(^NeuScreen,^Tags);
  726.          if XScreen=NIL then begin
  727.             OPENSMOOTH:=0;
  728.             exit;
  729.          end;
  730.          SetRGB32(^XScreen^.ViewPort,1,$BB000000,$BB000000,$FF000000);
  731.          ScreenToBack(XScreen);
  732.          WRITE(140,00,1,16,XScreen^,4,'Bitte Disk');
  733.          DName:=DName+' einlegen!';
  734.          WRITE(140,20,1,16,XScreen^,4,DName);
  735.          i:=0;
  736.          while (FHandle=0) and (i<3) do begin
  737.             i:=i+1;
  738.             ScreenToFront(XScreen);
  739.             repeat
  740.                delay(6);
  741.                FHandle:=DosOpen(FName,FMode);
  742.             until (LData^ and 64=0) or (FHandle<>0);
  743.             ScreenToBack(XScreen);
  744.             repeat
  745.                delay(6);
  746.             until not (LData^ and 64=0);
  747.             if FHandle=0 then FHandle:=DosOpen(FName,FMode);
  748.          end;
  749.          CloseScreen(XScreen);
  750.       end;
  751.    end;
  752.    OPENSMOOTH:=FHandle;
  753. end;
  754.  
  755.  
  756.  
  757. procedure RECT(XScreen :Screen, Color,LEdge,TEdge,REdge,BEdge :word);
  758.  
  759. begin
  760.    SetAPen(^XScreen.RastPort,Color);
  761.    RectFill(^XScreen.RastPort,LEdge,TEdge,REdge,BEdge);
  762. end;
  763.  
  764.  
  765.  
  766. procedure MAKEBORDER(XScreen :Screen; LEdge,TEdge,REdge,BEdge :word; Col1,Col2,Darken :byte);
  767.  
  768. begin
  769.    if Darken<>1 then RECT(XScreen,Darken,LEdge,TEdge,REdge,BEdge);
  770.    RECT(XScreen,Col1,LEdge,TEdge,LEdge+1,BEdge);
  771.    RECT(XScreen,Col1,LEdge+2,TEdge,REdge,TEdge+1);
  772.    RECT(XScreen,Col2,LEdge+2,BEdge-1,REdge,BEdge);
  773.    RECT(XScreen,Col2,REdge-1,TEdge+2,REdge,BEdge-1);
  774. end;
  775.  
  776.  
  777.  
  778.  
  779. procedure PRINTGLOBALINFOS(ActPlayer :byte);
  780.  
  781. begin
  782.    s:=intstr(Year);
  783.    WRITE(545,134,109,1,MyScreen[1]^,2,s);
  784.    if not Valid then exit;
  785.    if (Save.CivPlayer[ActPlayer]<>0) and Informed
  786.     then s:=intstr(Save.Staatstopf[ActPlayer]) else s:='0';
  787.    while length(s)>8 do s[length(s)]:=chr(0);
  788.    while length(s)<8 do s:=' '+s;
  789.    if (Save.CivPlayer[ActPlayer]<>0) or not Save.PlayMySelf then
  790.     WRITE(640,185,109,32+1,MyScreen[1]^,2,s);
  791.    if (Save.CivPlayer[ActPlayer]<>0) and Informed
  792.     then s:=intstr(Save.Bevölkerung[ActPlayer]) else s:='0';
  793.    while length(s)<8 do s:=' '+s;
  794.    while length(s)>8 do s[length(s)]:=chr(0);
  795.    if (Save.CivPlayer[ActPlayer]<>0) or not Save.PlayMySelf then
  796.     WRITE(521,236,109,1,MyScreen[1]^,2,s);
  797. end;
  798.  
  799.  
  800.  
  801. function GETCIVVAR(CivFlag :byte):byte;
  802.  
  803. begin
  804.    case (CivFlag and FLAG_CIV_MASK) of
  805.        FLAG_TERRA:   GETCIVVAR:=1;
  806.        FLAG_KLEGAN:  GETCIVVAR:=2;
  807.        FLAG_REMALO:  GETCIVVAR:=3;
  808.        FLAG_CARDAC:  GETCIVVAR:=4;
  809.        FLAG_FERAGI:  GETCIVVAR:=5;
  810.        FLAG_BAROJA:  GETCIVVAR:=6;
  811.        FLAG_VOLKAN:  GETCIVVAR:=7;
  812.        FLAG_OTHER:   GETCIVVAR:=8;
  813.        FLAG_MAQUES:  GETCIVVAR:=9;
  814.        otherwise GETCIVVAR:=0;
  815.    end;
  816. end;
  817.  
  818.  
  819.  
  820. function GETCIVADJ(CivVar :byte):string;
  821.  
  822. begin
  823.    case CivVar of
  824.       1: GETCIVADJ:='terranische';
  825.       2: GETCIVADJ:='klingonische';
  826.       3: GETCIVADJ:='romulanische';
  827.       4: GETCIVADJ:='kardassianische';
  828.       5: GETCIVADJ:='Ferengi-';
  829.       6: GETCIVADJ:='bajoranische';
  830.       7: GETCIVADJ:='vulkanische';
  831.       8: case Save.WorldFlag of
  832.             WFLAG_DCON:   GETCIVADJ:='tkonianische';
  833.             WFLAG_JAHADR: GETCIVADJ:='Jem´Hadar-';
  834.             otherwise GETCIVADJ:=GETCIVADJ(GETCIVVAR(Save.WorldFlag));
  835.          end;
  836.       otherwise GETCIVADJ:='ERROR: '+intstr(Civvar);
  837.    end;
  838. end;
  839.  
  840.  
  841.  
  842. function GETCIVNAME(CivVar :byte):string;
  843.  
  844. begin
  845.    case CivVar of
  846.       1: GETCIVNAME:='Terraner';
  847.       2: GETCIVNAME:='Klingonen';
  848.       3: GETCIVNAME:='Romulaner';
  849.       4: GETCIVNAME:='Kardassianer';
  850.       5: GETCIVNAME:='Ferengis';
  851.       6: GETCIVNAME:='Bajoraner';
  852.       7: GETCIVNAME:='Vulkanier';
  853.       8: case Save.WorldFlag of
  854.             WFLAG_CEBORC: GETCIVNAME:='Borg';
  855.             WFLAG_DCON:   GETCIVNAME:='Tkonianer';
  856.             WFLAG_JAHADR: GETCIVNAME:='Jem´Hadar';
  857.             otherwise GETCIVNAME:=GETCIVNAME(GETCIVVAR(Save.WorldFlag))
  858.          end;
  859.       9: GETCIVNAME:='Der Maquis';
  860.       otherwise GETCIVNAME:='ERROR: '+intstr(CivVar);
  861.    end;
  862. end;
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870. procedure CREATEJAHADR(ActPlayer :byte);
  871.  
  872. var i,j                 :byte;
  873. var MyPlanetHeader      :PlanetHeader;
  874. var MyShipPtr           :ShipHeader;
  875.  
  876. begin
  877.    if not Save.WorldFlag in [0,WFLAG_JAHADR] then exit;
  878.    Save.WorldFlag:=WFLAG_JAHADR;
  879.    for i:=1 to 8 do begin
  880.       Save.WarState[i,ActPlayer]:=LEVEL_DIED; Save.LastWarState[i,ActPlayer]:=LEVEL_DIED;
  881.       Save.WarState[i,8]:=LEVEL_UNKNOWN;
  882.       Save.WarState[8,i]:=LEVEL_UNKNOWN;
  883.    end;
  884.    Save.CivPlayer[8]:=0;
  885.    if Year>2050 then Save.Staatstopf[8]:=Save.Staatstopf[8]+abs(Year)*120
  886.    else Save.Staatstopf[8]:=20000;
  887.    Save.TechCosts[8,15]:=0;
  888.    Save.TechCosts[8,16]:=0;
  889.    Save.GSteuer[8]:=0;
  890.    for i:=1 to 42 do if Save.TechCosts[ActPlayer,i]<=0 then Save.TechCosts[8,i]:=0;
  891.    for i:=1 to Save.SYSTEMS do begin
  892.       for j:=1 to SystemHeader[i].Planets do begin
  893.          MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  894.          with MyPlanetHeader^ do if GETCIVVAR(PFlags)=ActPlayer then begin
  895.             PFlags:=FLAG_OTHER;
  896.             Ethno:=(PFlags and FLAG_CIV_MASK);
  897.             Save.Bevölkerung[8]:=Save.Bevölkerung[8]+Population;
  898.             Biosphäre:=200;   Infrastruktur:=200;   Industrie:=200;
  899.             if ProjectPtr<>NIL then begin
  900.                ProjectPtr^[1]:=1;  ProjectPtr^[25]:=1;
  901.                ProjectPtr^[30]:=1; ProjectPtr^[32]:=1;
  902.                PRojectPtr^[26]:=ProjectPtr^[26] or 16;
  903.                PRojectPtr^[27]:=ProjectPtr^[27] or 16;
  904.             end;
  905.             ProjectID:=0;
  906.             if FirstShip.NextShip<>NIL then begin
  907.                MyShipPtr:=FirstShip.NextShip;
  908.                repeat
  909.                   MyShipPtr^.Owner:=(PFlags and FLAG_CIV_MASK);
  910.                   MyShipPtr:=MyShipPtr^.NextShip;
  911.                until MyShipPtr=NIL;
  912.             end;
  913.          end;
  914.       end;
  915.    end;
  916. end;
  917.  
  918.  
  919.  
  920. procedure DRAWSTARS(Mode,ActPlayer :byte);
  921.  
  922. var i                   :integer;
  923. var MyShipPtr           :^r_ShipHeader;
  924. var MaxVal              :long;
  925. var Factor              :real;
  926. var CVal                :array [1..8] of long;
  927. var ActPlayerFlag       :byte;
  928.  
  929. begin
  930.    ActPlayerFlag:=GETCIVFLAG(ActPlayer);
  931.    Display:=0;
  932.    if Mode in [MODE_REDRAW,MODE_STARGATE] then begin
  933.       for i:=1 to 3 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,518,500-i*28);
  934.       WRITE(576,418,0,16,MyScreen[1]^,4,'Regierung');
  935.       WRITE(576,446,0,16,MyScreen[1]^,4,'Hauptmenü');
  936.       WRITE(576,474,8,16,MyScreen[1]^,4,'Rundenende');
  937.       RECT(MyScreen[1]^,0,0,0,511,511);
  938.       SetAPen(^MyScreen[1]^.RastPort,6);
  939.       for i:=1 to 310 do WritePixel(^MyScreen[1]^.RastPort,random(255)+random(255),random(255)+random(255));
  940.    end;
  941.    if Save.PlayMySelf then begin
  942.       MaxVal:=0;
  943.       for i:=1 to 8 do begin
  944.          CVal[i]:=Save.Bevölkerung[i]+Save.WarPower[i]*20+Save.ImperatorState[i]*10;
  945.          if CVal[i]>MaxVal then MaxVal:=CVal[i];
  946.       end;
  947.       Factor:=MaxVal/20;
  948.       for i:=1 to 8 do if (i<8) or not (Save.WorldFlag in [0,WFLAG_FIELD]) then begin
  949.          RECT(MyScreen[1]^,0            ,pred(i)*64,490,i*64-2,round(511-(CVal[i]/Factor)));
  950.          RECT(MyScreen[1]^,GETCIVFLAG(i),pred(i)*64,round(511-(CVal[i]/Factor)),i*64-2,511);
  951.          s:=intstr(CVal[i]);
  952.          WRITE(i*64+2,502,45,32,MyScreen[1]^,1,s);
  953.       end;
  954.    end;
  955.    SetAPen(^MyScreen[1]^.RastPort,12);
  956.    if Informed then for j:=1 to MAXHOLES do with MyWormHole[j] do for i:=1 to 2 do
  957.     if (CivKnowledge[ActPlayer]=FLAG_KNOWN)
  958.     and (System[1]<=Save.SYSTEMS) and (System[2]<=Save.SYSTEMS) then begin
  959.       Move(^MyScreen[1]^.RastPort,SystemX[System[1]],SystemY[System[1]]);
  960.       Draw(^MyScreen[1]^.RastPort,SystemX[System[2]],SystemY[System[2]]);
  961.    end;
  962.    for i:=1 to Save.SYSTEMS do if (SystemHeader[i].FirstShip.NextShip<>NIL)
  963.    and (Mode<>MODE_STARGATE) then begin
  964.       SetAPen(^MyScreen[1]^.RastPort,ActPlayerFlag);
  965.       MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  966.       while (MyShipPtr<>NIL) and (MyShipPtr^.NextShip<>MyShipPtr) do begin
  967.          if (MyShipPtr^.Moving<0) and (MyShipPtr^.Owner=ActPlayerFlag)
  968.          and (Save.CivPlayer[ActPlayer]<>0) and Informed
  969.          and (MyShipPtr^.Source in [1..Save.SYSTEMS])
  970.          and (MyShipPtr^.Target in [1..Save.Systems]) then begin
  971.             Move(^MyScreen[1]^.RastPort,SystemX[MyShipPtr^.Source],SystemY[MyShipPtr^.Source]);
  972.             Draw(^MyScreen[1]^.RastPort,SystemX[MyShipPtr^.Target],SystemY[MyShipPtr^.Target]);
  973.          end;
  974.          MyShipPtr:=MyShipPtr^.NextShip;
  975.       end;
  976.    end;
  977.    for i:=1 to Save.SYSTEMS do begin
  978.       if not Save.PlayMySelf and
  979.       (((SystemFlags[ActPlayer,i] and FLAG_KNOWN<>FLAG_KNOWN) or (Save.CivPlayer[ActPlayer]=0)
  980.       or not Informed) and (SystemHeader[i].vNS<>FLAG_KNOWN) or ((Mode=MODE_STARGATE)
  981.       and (SystemHeader[i].FirstShip.SType<>TARGET_STARGATE))) then begin
  982.          RECT(MyScreen[1]^,0,pred(SystemX[i]),pred(SystemY[i]),succ(SystemX[i]),succ(SystemY[i]));
  983.          SetAPen(^MyScreen[1]^.RastPort,12);
  984.          WritePixel(^MyScreen[1]^.RastPort,SystemX[i],SystemY[i]);
  985.          WRITE(SystemX[i]+3,SystemY[i]+3,12,1,MyScreen[1]^,1,Save.SystemName[i]);
  986.       end else if (SystemFlags[1,i] and FLAG_CIV_MASK<>0) then begin
  987.          SetAPen(^MyScreen[1]^.RastPort,SystemFlags[1,i] and FLAG_CIV_MASK);
  988.          if (SystemHeader[i].FirstShip.SType=TARGET_STARGATE)
  989.           then DrawEllipse(^MyScreen[1]^.RastPort,SystemX[i],SystemY[i],4,4)
  990.           else RECT(MyScreen[1]^,SystemFlags[1,i] and FLAG_CIV_MASK,pred(SystemX[i]),pred(SystemY[i]),succ(SystemX[i]),succ(SystemY[i]));
  991.          WRITE(SystemX[i]+3,SystemY[i]+3,SystemFlags[1,i] and FLAG_CIV_MASK,1,MyScreen[1]^,1,Save.SystemName[i]);
  992.       end else begin
  993.          SetAPen(^MyScreen[1]^.RastPort,12);
  994.          if (SystemHeader[i].FirstShip.SType=TARGET_STARGATE)
  995.           then DrawEllipse(^MyScreen[1]^.RastPort,SystemX[i],SystemY[i],4,4)
  996.           else RECT(MyScreen[1]^,12,pred(SystemX[i]),pred(SystemY[i]),succ(SystemX[i]),succ(SystemY[i]));
  997.          WRITE(SystemX[i]+3,SystemY[i]+3,12,1,MyScreen[1]^,1,Save.SystemName[i]);
  998.       end;
  999.    end;
  1000.    PRINTGLOBALINFOS(ActPlayer);
  1001.    if not Save.PlayMySelf then ScreenToFront(MyScreen[1]);
  1002. end;
  1003.  
  1004.  
  1005.  
  1006. procedure BOX(XScreen :Screen; Left,Top,Right,Bottom :word);
  1007.  
  1008. type BoxArr=array [1..8] of word;
  1009.  
  1010. var BArr        :BoxArr;
  1011.  
  1012. begin
  1013.    BArr:=BoxArr(Right,Top,Right,Bottom,Left,Bottom,Left,Top);
  1014.    Move(^XScreen.RastPort,Left,Top);
  1015.    PolyDraw(^XScreen.RastPort,4,^BArr);
  1016. end;
  1017.  
  1018.  
  1019.  
  1020. procedure DRAWSYSTEM(Mode,ActSys :byte; ActShipPtr :ptr);
  1021.  
  1022. var x,y,i                       :integer;
  1023. var l                           :long;
  1024. var MyShipPtr,UseShipPtr        :^r_ShipHeader;
  1025. var PlanetHeader                :^r_PlanetHeader;
  1026. var Leave,j                     :byte;
  1027.  
  1028. begin
  1029.    OldX:=OffsetX; OldY:=OffsetY;
  1030.    if Mode=MODE_REDRAW then begin
  1031.       if Display in [0,100] then begin
  1032.          for i:=1 to 3 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,518,500-i*28);
  1033.          WRITE(576,418,0,16,MyScreen[1]^,4,'Suchen');
  1034.          WRITE(576,446,0,16,MyScreen[1]^,4,'Sternenkarte');
  1035.          WRITE(576,474,8,16,MyScreen[1]^,4,'Rundenende');
  1036.       end;
  1037.       Display:=ActSys;
  1038.       RECT(MyScreen[1]^,0,522,9,629,116);
  1039.       RECT(MyScreen[1]^,0,0,0,511,511);
  1040.       RECT(MyScreen[1]^,10,575,62,577,63);
  1041.    end;
  1042.    Display:=ActSys;
  1043.    SetAPen(^MyScreen[1]^.RastPort,109);
  1044.    x:=63-OffsetY-10;                   y:=63-OffsetY+8;
  1045.    if x<9 then x:=9;                   if y>116 then y:=116;
  1046.    Move(^MyScreen[1]^.RastPort,522,x); Draw(^MyScreen[1]^.RastPort,629,x);
  1047.    Move(^MyScreen[1]^.RastPort,522,y); Draw(^MyScreen[1]^.RastPort,629,y);
  1048.    x:=576-OffsetX-10;                y:=576-OffsetX+8;
  1049.    if x<522 then x:=522;             if y>629 then y:=629;
  1050.    Move(^MyScreen[1]^.RastPort,x,9); Draw(^MyScreen[1]^.RastPort,x,116);
  1051.    Move(^MyScreen[1]^.RastPort,y,9); Draw(^MyScreen[1]^.RastPort,y,116);
  1052.    if (OffsetX in [-7..7]) and (OffsetY in [-7..7]) then begin
  1053.       BltBitMapRastPort(^ImgBitMap7,288,0,^MyScreen[1]^.RastPort,224+OffsetX*32,224+OffsetY*32,64,32,192);
  1054.       BltBitMapRastPort(^ImgBitMap7,352,0,^MyScreen[1]^.RastPort,224+OffsetX*32,256+OffsetY*32,64,32,192);
  1055.    end;
  1056.    SetAPen(^MyScreen[1]^.RastPort,12);
  1057.    for j:=1 to MAXHOLES do with MyWormHole[j] do for i:=1 to 2 do if System[i]=ActSys then begin
  1058.       x:=256+round(PosX[i]+OffsetX)*32;
  1059.       y:=256+round(PosY[i]+OffsetY)*32;
  1060.       if (x in [0..480]) and (y in [0..480]) then begin
  1061.          RectFill(^MyScreen[1]^.RastPort,x+15,Y+15,x+17,y+17);
  1062.          if (x in [32..448]) and (y in [32..448]) then
  1063.           if (SystemFlags[1,System[3-i]] and FLAG_CIV_MASK=0) then WRITE(x+16,y+20,12,16,MyScreen[1]^,1,Save.SystemName[System[3-i]])
  1064.           else WRITE(x+16,y+20,SystemFlags[1,System[3-i]] and FLAG_CIV_MASK,16,MyScreen[1]^,1,Save.SystemName[System[3-i]]);
  1065.          if Save.CivPlayer[ActPlayer]<>0 then CivKnowledge[ActPlayer]:=FLAG_KNOWN;
  1066.       end;
  1067.       if CivKnowledge[ActPlayer]=FLAG_KNOWN then WritePixel(^MyScreen[1]^.RastPort,575+PosX[i],62+PosY[i]);
  1068.    end;
  1069.    for i:=1 to SystemHeader[ActSys].Planets do begin
  1070.       PlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(i)*sizeof(r_PlanetHeader));
  1071.       with PlanetHeader^ do begin
  1072.          if Mode=MODE_REDRAW then begin
  1073.             if PFlags>0 then SetAPen(^MyScreen[1]^.RastPort,PFlags) else SetAPen(^MyScreen[1]^.RastPort,12);
  1074.             RectFill(^MyScreen[1]^.RastPort,575+round(PosX),62+round(PosY),576+round(PosX),63+round(PosY));
  1075.          end;
  1076.          x:=256+round(PosX+OffsetX)*32;
  1077.          y:=256+round(PosY+OffsetY)*32;
  1078.          if (x in [0..480]) and (y in [0..480]) then begin
  1079.             BltBitMapRastPort(^ImgBitMap7,Class*32,0,^MyScreen[1]^.RastPort,x,y,32,32,192);
  1080.             if (x in [32..448]) and (y in [32..448]) then begin
  1081.                MyShipPtr:=FirstShip.NextShip;
  1082.                while (MyShipPtr<>NIL) and (MyShipPtr^.Owner=0) do MyShipPtr:=MyShipPtr^.NextShip;
  1083.                if MyShipPtr<>NIL then SetAPen(^MyScreen[1]^.RastPort,MyShipPtr^.Owner and FLAG_CIV_MASK)
  1084.                else SetAPen(^MyScreen[1]^.RastPort,0);
  1085.                DrawEllipse(^MyScreen[1]^.RastPort,x+15,y+15,24,23);
  1086.                if ProjectPtr^[25]=1 then BltBitMapRastPort(^ImgBitMap4,544,32,^MyScreen[1]^.RastPort,x-18,y+10,15,14,192);
  1087.                if PFlags>0 then begin
  1088.                   if (ProjectPtr^[34]<>0) or (ProjectPtr^[40]<>0) then
  1089.                    WRITE(x+15,y+32,PFlags,21,MyScreen[1]^,1,PName)
  1090.                   else WRITE(x+15,y+32,PFlags,17,MyScreen[1]^,1,PName);
  1091.                end else begin
  1092.                   if (ProjectPtr<>NIL) and
  1093.                   ((ProjectPtr^[34]>0) or (ProjectPtr^[40]>0)) then
  1094.                    WRITE(x+15,y+32,12,21,MyScreen[1]^,1,PName)
  1095.                   else WRITE(x+15,y+32,12,17,MyScreen[1]^,1,PName);
  1096.                end;
  1097.             end;
  1098.          end;
  1099.       end;
  1100.    end;
  1101.    Leave:=0;
  1102.    MyShipPtr:=^SystemHeader[ActSys].FirstShip;
  1103.    while (MyShipPtr<>NIL) and (Leave<2) do begin
  1104.       if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  1105.          UseShipPtr:=MyShipPtr^.TargetShip;
  1106.          while (UseShipPtr<>NIL) and (UseShipPtr^.Owner=0) do UseShipPtr:=UseShipPtr^.NextShip;
  1107.       end else UseShipPtr:=MyShipPtr;
  1108.       if UseShipPtr<>NIL then
  1109.       if (MyShipPtr^.Owner>0) and (UseShipPtr^.Owner>0) and (MyShipPtr^.Moving>=0)
  1110.       and (MyShipPtr^.SType>0) or (MyShipPtr^.SType=TARGET_STARGATE) then begin
  1111.          x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  1112.          y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  1113.          if MyShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=MyShipPtr^.TargetShip
  1114.          else UseShipPtr:=MyShipPtr;
  1115.          if (x in [0..480]) and (y in [0..480]) then begin
  1116.             RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  1117.             BltBitMapRastPort(^ImgBitMap4,(UseShipPtr^.SType-8)*32,32,^MyScreen[1]^.RastPort,x,y,31,31,192);
  1118.          end;
  1119.          if UseShipPtr^.SType<>TARGET_STARGATE then SetAPen(^MyScreen[1]^.RastPort,MyShipPtr^.Owner)
  1120.          else SetAPen(^MyScreen[1]^.RastPort,12);
  1121.          WritePixel(^MyScreen[1]^.RastPort,575+MyShipPtr^.PosX,62+MyShipPtr^.PosY);
  1122.          if (x in [0..480]) and (y in [0..480]) and (MyShipPtr^.SType<>TARGET_STARGATE) then begin
  1123.             BOX(MyScreen[1]^,x,y,x+31,y+31);
  1124.             if MyShipPtr^.SType=SHIPTYPE_FLEET then BOX(MyScreen[1]^,x+2,y+2,x+29,y+29);
  1125.             if MyShipPtr^.Flags=SHIPFLAG_WATER then begin
  1126.                WRITE(x+8,y+10,0,0,MyScreen[1]^,4,'W');
  1127.                WRITE(x+7,y+9,12,0,MyScreen[1]^,4,'W');
  1128.             end;
  1129.             if MyShipPtr^.Target=TARGET_POSITION then begin
  1130.                WRITE(x+11,y+10,0,0,MyScreen[1]^,4,'P');
  1131.                WRITE(x+10,y+9,12,0,MyScreen[1]^,4,'P');
  1132.             end;
  1133.          end;
  1134.       end;
  1135.       MyShipPtr:=MyShipPtr^.NextShip;
  1136.       if Leave=1 then Leave:=2;
  1137.       if (MyShipPtr=NIL) and (Leave=0) then begin
  1138.          MyShipPtr:=ActShipPtr;
  1139.          Leave:=1;
  1140.       end;
  1141.    end;
  1142.    if (SystemFlags[1,ActSys] and FLAG_CIV_MASK=0) then WRITE(200,491,12,0,MyScreen[1]^,4,Save.SystemName[ActSys])
  1143.    else WRITE(200,491,SystemFlags[1,ActSys] and FLAG_CIV_MASK,0,MyScreen[1]^,4,Save.SystemName[ActSys]);
  1144.    PRINTGLOBALINFOS(ActPlayer);
  1145.    if not Save.PlayMySelf then ScreenToFront(MyScreen[1]);
  1146. end;
  1147.  
  1148.  
  1149.  
  1150. procedure KLICKGAD(x,y :word);
  1151.  
  1152. begin
  1153.    ClipBlit(^MyScreen[1]^.RastPort,x,y,^XScreen^.RastPort,0,0,116,20,192);
  1154.    DrawImage(^MyScreen[1]^.RastPort,^GadImg2,x,y);
  1155.    PLAYSOUND(1,300);
  1156.    ClipBlit(^XScreen^.RastPort,0,0,^MyScreen[1]^.RastPort,x,y,116,20,192);
  1157. end;
  1158.  
  1159.  
  1160.  
  1161. function FINDOBJECT(ActSys :byte; GetX,GetY :integer; ExcludeObj :ptr):boolean;
  1162.  
  1163. var ActShipPtr          :^r_ShipHeader;
  1164. var x,y,i               :integer;
  1165. var PlanetHeader        :^r_PlanetHeader;
  1166. var j                   :byte;
  1167.  
  1168. begin
  1169.    FINDOBJECT:=true;
  1170.    ObjPtr:=NIL; ObjType:=0;
  1171.    i:=1;
  1172.    ActShipPtr:=ExcludeObj;
  1173.    if (SystemHeader[ActSys].FirstShip.SType=TARGET_STARGATE)
  1174.    and (ActShipPtr<>NIL) and (ActShipPtr^.SType<>TARGET_STARGATE) then begin
  1175.       x:=256+(SystemHeader[ActSys].FirstShip.PosX+OffsetX)*32;
  1176.       y:=256+(SystemHeader[ActSys].FirstShip.PosY+OffsetY)*32;
  1177.       if (GetX in [x..x+32]) and (GetY in [y..y+32]) and (PlanetHeader<>ExcludeObj) then begin
  1178.          ObjType:=TYPE_STARGATE; exit;
  1179.       end;
  1180.    end;
  1181.    repeat
  1182.       PlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(i)*sizeof(r_PlanetHeader));
  1183.       x:=256+round(PlanetHeader^.PosX+OffsetX)*32;
  1184.       y:=256+round(PlanetHeader^.PosY+OffsetY)*32;
  1185.       if (GetX in [x..x+32]) and (GetY in [y..y+32]) and (PlanetHeader<>ExcludeObj) then begin
  1186.          ObjType:=TYPE_PLANET; ObjPtr:=PlanetHeader; exit;
  1187.       end;
  1188.       i:=i+1;
  1189.    until (i>SystemHeader[ActSys].Planets);
  1190.    if SystemHeader[ActSys].FirstShip.NextShip<>NIL then begin
  1191.       ActShipPtr:=SystemHeader[ActSys].FirstShip.NextShip;
  1192.       repeat
  1193.          x:=256+(ActShipPtr^.PosX+OffsetX)*32;
  1194.          y:=256+(ActShipPtr^.PosY+OffsetY)*32;
  1195.          if (GetX in [x..x+32]) and (GetY in [y..y+32])
  1196.          and (ActShipPtr<>ExcludeObj)
  1197.          and (ActShipPtr^.Owner<>0)
  1198.          and (ActShipPtr^.Moving>=0) then begin
  1199.             ObjType:=TYPE_SHIP; ObjPtr:=ActShipPtr;
  1200.             exit;
  1201.          end;
  1202.          ActShipPtr:=ActShipPtr^.NextShip;
  1203.       until ActShipPtr=NIL;
  1204.    end;
  1205.    for i:=1 to MAXHOLES do with MyWormHole[i] do for j:=1 to 2 do if System[j]=ActSys then begin
  1206.       x:=256+(PosX[j]+OffsetX)*32;
  1207.       y:=256+(PosY[j]+OffsetY)*32;
  1208.       if (GetX in [x..x+32]) and (GetY in [y..y+32]) then begin
  1209.          ObjType:=TYPE_WORMHOLE; ObjPtr:=NIL;
  1210.          exit;
  1211.       end;
  1212.    end;
  1213.    FINDOBJECT:=false;
  1214. end;
  1215.  
  1216.  
  1217.  
  1218. procedure INITSTDTAGS;
  1219.  
  1220. begin
  1221.    Pens:=PenArr(0,0,0,0,0,0,0,0,0,0,0,0,0);
  1222.    ColSpec:=ColSpecArr(0,0,0,0,-1);
  1223.    Tags:=TagArr(SA_DisplayID,   ($9004+HelpID),
  1224.                 SA_Interleaved, _TRUE,
  1225.                 SA_DRAGGABLE,   _FALSE,
  1226.                 SA_PENS,        addr(Pens),
  1227.                 SA_COLORS,      addr(ColSpec),
  1228.                 TAG_DONE,       0,0,0);
  1229. end;
  1230.  
  1231.  
  1232.  
  1233. function OPENMAINSCREENS:boolean;
  1234.  
  1235. var i   :byte;
  1236.  
  1237. begin
  1238.    IMemID:=false;
  1239.    OPENMAINSCREENS:=false;
  1240.    for i:=1 to 2 do MyScreen[i]:=NIL;
  1241.    for i:=1 to 2 do MyWindow[i]:=NIL;
  1242.    NeuScreen:=NewScreen(0,0,640,512,7,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,
  1243.                         NIL,'',NIL,NIL);
  1244.    INITSTDTAGS;
  1245.    MyScreen[1]:=OpenScreenTagList(^NeuScreen,^Tags);
  1246.    if MyScreen[1]=NIL then exit;
  1247.    NeuScreen:=NewScreen(0,0,640,512,8,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,
  1248.                         NIL,'',NIL,NIL);
  1249.    MyScreen[2]:=OpenScreenTagList(^NeuScreen,^Tags);
  1250.    if MyScreen[2]=NIL then exit;
  1251.    for i:=1 to 2 do with MyScreen[i]^ do begin
  1252.       BarHeight:=0;  WBorTop:=0; MenuVBorder:=0; MenuHBorder:=0;
  1253.    end;
  1254.    for i:=1 to 2 do begin
  1255.       NeuWindow:=NewWindow(0,0,640,512,0,0,RAWKEY,SIMPLE_REFRESH+BACKDROP+BORDERLESS,
  1256.                            NIL,NIL,'',MyScreen[i],NIL,640,512,640,512,CUSTOMSCREEN);
  1257.       MyWindow[i]:=OpenWindow(^NeuWindow);
  1258.       if MyWindow[i]=NIL then exit;
  1259.    end;
  1260.    OPENMAINSCREENS:=true;
  1261. end;
  1262.  
  1263.  
  1264.  
  1265. procedure UNPACK(Anfang,PackedD,Laenge :long; Mode :byte);
  1266.  
  1267. var Anz,Inh,Dest               :^byte;
  1268. var UnPackedD,l                :long;
  1269. var i                          :integer;
  1270.  
  1271.  
  1272. procedure LEVEL1;
  1273.  
  1274. begin
  1275.    UnPackedD:=Anfang;
  1276.    repeat
  1277.       Anz:=ptr(PackedD);   PackedD:=PackedD+1;
  1278.       if Anz^>127 then begin
  1279.          Anz^:=Anz^-127;
  1280.          CopyMem(PackedD,UnPackedD,Anz^);
  1281.          PackedD:=PackedD+Anz^;
  1282.          UnPackedD:=UnPackedD+Anz^;
  1283.       end else begin
  1284.          Inh:=ptr(PackedD);   PackedD:=PackedD+1;
  1285.          for i:=1 to Anz^ do begin
  1286.             Dest:=Ptr(UnPackedD); UnPackedD:=UnPackedD+1;
  1287.             Dest^:=Inh^;
  1288.          end;
  1289.       end;
  1290.    until (UnPackedD>=PackedD) or (UnPackedD>=Anfang+Laenge);
  1291. end;
  1292.  
  1293.  
  1294. begin
  1295.    if Mode=0 then SWITCHDISPLAY;
  1296.    UnPackedD:=Anfang;
  1297.    LEVEL1;
  1298. end;
  1299.  
  1300.  
  1301.  
  1302. function SETCOLOR(XScreen :Screen; FName :str):byte;
  1303.  
  1304. type r_Col=record;
  1305.         r,g,b   :byte
  1306.      end;
  1307.  
  1308. var AddrX,l,ISize       :long;
  1309. var i                   :integer;
  1310. var ColorID             :^long;
  1311. var Col                 :^r_Col;
  1312. var FHandle             :BPTR;
  1313.  
  1314. begin
  1315.    SETCOLOR:=0;
  1316.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  1317.    if FHandle=0 then exit;
  1318.    l:=DosSeek(FHandle,0,OFFSET_END);
  1319.    ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  1320.    l:=DosRead(FHandle,ptr(IMemA[0]),ISize);
  1321.    DosClose(FHandle);
  1322.    AddrX:=IMemA[0];
  1323.    repeat
  1324.       ColorID:=ptr(AddrX); AddrX:=AddrX+4;
  1325.    until (AddrX>=IMemA[0]+ISize) or (ColorID^=$434D4150);
  1326.    if ColorID^=$434D4150 then begin
  1327.       AddrX:=AddrX+4;
  1328.       i:=0;
  1329.       repeat
  1330.          Col:=ptr(AddrX); AddrX:=AddrX+3;
  1331.          SetRGB32(^XScreen.ViewPort,i,Col^.r*$1000000,Col^.g*$1000000,Col^.b*$1000000);
  1332.          i:=i+1;
  1333.       until (AddrX>=IMemA[0]+ISize);
  1334.       l:=(ISize-8) div 3;
  1335.       i:=0;
  1336.       repeat
  1337.          l:=l div 2; i:=i+1;
  1338.       until l<=1;
  1339.       SETCOLOR:=i;
  1340.    end;
  1341. end;
  1342.  
  1343.  
  1344.  
  1345. function RAWLOADIMAGE(Fn :str; LEdge,TEdge,Width,Height,Depth :integer; DestBitMap :ITBitMap):boolean;
  1346.  
  1347. type PLANEArr=array [0..7] of PLANEPTR;
  1348.  
  1349. var FName               :string[120];
  1350. var FHandle             :BPTR;
  1351. var CNum,i              :word;
  1352. var ISize,l,Addr        :long;
  1353. var Size,Colors         :^long;
  1354. var Valid               :boolean;
  1355. var MyBitMap            :BitMap;
  1356. var MyPLANEPTR          :PLANEArr;
  1357.  
  1358. begin
  1359.    RAWLOADIMAGE:=false;
  1360.    FName:=Fn;
  1361.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  1362.    if FHandle=0 then exit;
  1363.    ISize:=DosSeek(FHandle,0,OFFSET_END);
  1364.    ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  1365.    l:=DosRead(FHandle,ptr(IMemA[0]+IMemL[0]-ISize-250),ISize);
  1366.    DosClose(FHandle);
  1367.    l:=Width*Height;
  1368.    l:=l*Depth div 8;
  1369.    UNPACK(IMemA[0],IMemA[0]+IMemL[0]-ISize-250,l,0);
  1370.    if (l=DestBitMap.MemL) and (Depth=4) then CopyMemQuick(IMemA[0],DestBitMap.MemA,DestBitMap.MemL) else begin
  1371.       ISize:=(Width*Height) div 8;
  1372.       MyPLANEPTR:=PLANEArr(ptr(IMemA[0]),        ptr(IMemA[0]+ISize),  ptr(IMemA[0]+ISize*2),
  1373.                            ptr(IMemA[0]+ISize*3),ptr(IMemA[0]+ISize*4),ptr(IMemA[0]+ISize*5),
  1374.                            ptr(IMemA[0]+ISize*6),ptr(IMemA[0]+ISize*7));
  1375.       MyBitMap:=BitMap(Width div 8,Height,1,Depth,0,MyPLANEPTR);
  1376.       l:=BltBitMap(^MyBitMap,0,0,^DestBitMap,LEdge,TEdge,Width,Height,192,$FF,NIL);
  1377.    end;
  1378.    RAWLOADIMAGE:=true;
  1379. end;
  1380.  
  1381.  
  1382.  
  1383. function DISPLAYIMAGE(Fn :str; LEdge,TEdge,Width,Height,Depth :integer; XScreen :Screen, CacheNum :byte):boolean;
  1384.  
  1385. type r_RGB=record
  1386.         r,g,b   :byte;
  1387.      end;
  1388.  
  1389. var FName               :string[120];
  1390. var FHandle             :BPTR;
  1391. var CNum,i              :word;
  1392. var ISize,l,Addr        :long;
  1393. var Size,Colors         :^long;
  1394. var RGB                 :^r_RGB;
  1395. var Valid               :boolean;
  1396.  
  1397. begin
  1398.    DISPLAYIMAGE:=false;
  1399.    FName:=Fn;
  1400.    Valid:=false;
  1401.    IMemID:=false;
  1402.    if CacheNum>0 then if CacheMemA[CacheNum]>0 then Valid:=true;
  1403.    if not Valid then begin
  1404.       FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  1405.       if FHandle=0 then exit;
  1406.       ISize:=DosSeek(FHandle,0,OFFSET_END);
  1407.       ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  1408.       l:=DosRead(FHandle,ptr(IMemA[0]+IMemL[0]-ISize-250),ISize);
  1409.       l:=Width*Height;
  1410.       l:=l*Depth div 8;
  1411.       UNPACK(IMemA[0],IMemA[0]+IMemL[0]-ISize-250,l,0);
  1412.       DosClose(FHandle);
  1413.    end;
  1414.    Case Depth of
  1415.       2: CNum:=4;
  1416.       3: CNum:=8;
  1417.       4: CNum:=16;
  1418.       5: CNum:=32;
  1419.       6: CNum:=64;
  1420.       7: CNum:=128;
  1421.       8: CNum:=256;
  1422.       otherwise CNum:=1;
  1423.    end;
  1424.    if Valid then CopyMemQuick((CacheMemA[CacheNum]+CNum*3+8),IMemA[0],(CacheMemL[CacheNum]-CNum*3-8));
  1425.    Img:=Image(0,0,Width,Height,Depth,ptr(IMemA[0]),pred(CNum),0,NIL);
  1426.    DrawImage(^XScreen.RastPort,^Img,LEdge,TEdge);
  1427.    if (CacheNum>0) and not Valid then begin
  1428.       CacheMemL[CacheNum]:=l+CNum*3+8;
  1429.       CacheMemA[CacheNum]:=AllocMem(CacheMemL[CacheNum],MEMF_FAST);
  1430.       if CacheMemA[CacheNum]>0 then begin
  1431.          Addr:=CacheMemA[CacheNum];
  1432.          Size:=Ptr(Addr);   Size^:=l;      Addr:=Addr+4;
  1433.          Colors:=ptr(Addr); Colors^:=CNum; Addr:=Addr+4;
  1434.          FName[length(FName)-2]:=chr(0);
  1435.          FName:=FName+'pal';
  1436.          FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  1437.          if FHandle<>0 then begin
  1438.             l:=DosSeek(FHandle,8,OFFSET_BEGINNING);
  1439.             l:=DosRead(FHandle,ptr(Addr),CNum*3);
  1440.             DosClose(FHandle);
  1441.          end;
  1442.          Addr:=Addr+CNum*3;
  1443.          CopyMemQuick(IMemA[0],Addr,Size^);
  1444.          Valid:=true;
  1445.       end else begin
  1446.          FName[length(FName)-2]:=chr(0);
  1447.          FName:=FName+'pal';
  1448.          l:=SETCOLOR(XScreen,FName);
  1449.       end;
  1450.    end;
  1451.    if Valid then begin
  1452.       Addr:=CacheMemA[CacheNum];
  1453.       Size:=Ptr(Addr);   Addr:=Addr+4;
  1454.       Colors:=ptr(Addr); Addr:=Addr+4;
  1455.       for i:=0 to pred(Colors^) do begin
  1456.          RGB:=ptr(Addr); Addr:=Addr+3;
  1457.          SetRGB32(^XScreen.ViewPort,i,RGB^.r*$1000000,RGB^.g*$1000000,RGB^.b*$1000000);
  1458.       end;
  1459.    end;
  1460.    DISPLAYIMAGE:=true;
  1461. end;
  1462.  
  1463.  
  1464.  
  1465. function OPENCINEMA(Depth :byte):ptr;
  1466.  
  1467. begin
  1468.    INITSTDTAGS;
  1469.    NeuScreen:=NewScreen(0,0,640,435,Depth,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,
  1470.                         NIL,'',NIL,NIL);
  1471.    OPENCINEMA:=OpenScreenTagList(^NeuScreen,^Tags);
  1472. end;
  1473.  
  1474.  
  1475.  
  1476. procedure MAININTRO;
  1477.  
  1478. const ROTATE_PX=1;
  1479. const ROTATE_PY=2;
  1480. const ROTATE_PZ=4;
  1481. const ROTATE_NX=8;
  1482. const ROTATE_NY=16;
  1483. const ROTATE_NZ=32;
  1484.  
  1485. type r_RGB=record
  1486.         r,g,b   :byte;
  1487.      end;
  1488. type r_Coords=array [0..40] of real;
  1489. type StrArr=array [1..20] of str;
  1490. type FontArr=array [1..20] of byte;
  1491. type CArr=array[1..6] of real;
  1492. type PlaneArr=array [0..7] of PLANEPTR;
  1493.  
  1494. type VectorObj=record
  1495.         PosX,PosY               :integer;
  1496.         Flag,Size1,Size2        :byte;
  1497.         X1,Y1,Z1,X2,Y2,Z2       :CArr;
  1498.      end;
  1499.  
  1500. var Factor,SizeFactor,FactorCos,
  1501.     FactorSin,FactorMSin,
  1502.     FactorMCos                  :real;
  1503. var SArr                        :strArr;
  1504. var FArr                        :FontArr;
  1505. var i,j,k                       :integer;
  1506. var l,ISize                     :long;
  1507. var AScr,btx                    :byte;
  1508. var FHandle                     :BPTR;
  1509. var Col                         :^r_RGB;
  1510. var Colors                      :array [0..127] of r_RGB;
  1511. var MyRastPtr                   :ptr;
  1512. var MyTmpRas                    :TmpRas;
  1513. var MyAI                        :AreaInfo;
  1514. var VObj                        :array [1..13] of VectorObj;
  1515. var MyBitMap                    :BitMap;
  1516. var MyPlanePtr                  :PlaneArr;
  1517. var ShipX,ShipY,ShipZ           :r_Coords;
  1518. var LEdge,TEdge                 :array [1..2] of integer;
  1519. var SMemA,SMemL                 :array [1..3] of long;
  1520. var IntroBitMap                 :ITBitMap;
  1521.  
  1522.  
  1523. procedure SETDARKCOLOR(FName :str);
  1524.  
  1525. var AddrX,l,ISize       :long;
  1526. var i                   :integer;
  1527. var ColorID             :^long;
  1528. var FHandle             :BPTR;
  1529.  
  1530. begin
  1531.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  1532.    if FHandle=0 then exit;
  1533.    l:=DosSeek(FHandle,0,OFFSET_END);
  1534.    ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  1535.    l:=DosRead(FHandle,ptr(IMemA[0]),ISize);
  1536.    DosClose(FHandle);
  1537.    AddrX:=IMemA[0];
  1538.    repeat
  1539.       ColorID:=ptr(AddrX); AddrX:=AddrX+4;
  1540.    until (AddrX>=IMemA[0]+ISize) or (ColorID^=$434D4150);
  1541.    if ColorID^=$434D4150 then begin
  1542.       AddrX:=AddrX+4;
  1543.       i:=0;
  1544.       repeat
  1545.          Col:=ptr(AddrX); AddrX:=AddrX+3;
  1546.          Colors[i]:=Col^;
  1547.          SetRGB32(^MyScreen[1]^.ViewPort,i,0,0,0);
  1548.          SetRGB32(^MyScreen[2]^.ViewPort,i,0,0,0);
  1549.          i:=i+1;
  1550.       until (AddrX>=IMemA[0]+ISize);
  1551.    end;
  1552.    Colors[31]:=r_RGB(45,45,62)
  1553. end;
  1554.  
  1555.  
  1556.  
  1557. procedure INTROEXIT;
  1558.  
  1559. begin
  1560.    SWITCHDISPLAY;
  1561.    i:=SetTaskPri(FindTask(NIL),0);
  1562.    if MyRastPtr<>NIL then FreeRaster(MyRastPtr,640,360);
  1563.    MyRastPtr:=NIL;
  1564.    for i:=1 to 2 do if MyScreen[i]<>NIL then RECT(MyScreen[i]^,0,0,75,639,434);
  1565.    for i:=1 to 2 do if MyScreen[i]<>NIL then begin
  1566.       CloseScreen(MyScreen[i]); MyScreen[i]:=NIL;
  1567.    end;
  1568.    for i:=1 to 3 do if SMemA[i]>0 then begin
  1569.       FreeMem(SMemA[i],SMemL[i]);
  1570.       SMemA[i]:=0;
  1571.    end;
  1572.    for i:=0 to 1 do if IMemA[i]>0 then begin
  1573.       FreeMem(IMemA[i],IMemL[i]);
  1574.       IMemA[i]:=0;
  1575.    end;
  1576.    if TMPTR<>0 then begin
  1577.       StopPlayer;
  1578.       UnloadModule(TMPTR);
  1579.    end;
  1580.    TMPTR:=0;
  1581.    DMACON_WRITE^:=$000F;
  1582. end;
  1583.  
  1584.  
  1585. procedure ROTATEpX(k :byte);
  1586. var i   :byte;
  1587. begin
  1588.    with VObj[k] do begin
  1589.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1590.          Y1[i]:=Y1[i]*FactorCos-Z1[i]*FactorSin;
  1591.          Z1[i]:=Y1[i]*FactorSin+Z1[i]*FactorCos;
  1592.       end;
  1593.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1594.          Y2[i]:=Y2[i]*FactorCos-Z2[i]*FactorSin;
  1595.          Z2[i]:=Y2[i]*FactorSin+Z2[i]*FactorCos;
  1596.       end;
  1597.    end;
  1598. end;
  1599.  
  1600.  
  1601. procedure ROTATEpY(k :byte);
  1602. var i   :byte;
  1603. begin
  1604.    with VObj[k] do begin
  1605.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1606.          X1[i]:=X1[i]*FactorCos-Z1[i]*FactorSin;
  1607.          Z1[i]:=Z1[i]*FactorCos+X1[i]*FactorSin;
  1608.       end;
  1609.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1610.          X2[i]:=X2[i]*FactorCos-Z2[i]*FactorSin;
  1611.          Z2[i]:=Z2[i]*FactorCos+X2[i]*FactorSin;
  1612.       end;
  1613.    end;
  1614. end;
  1615.  
  1616.  
  1617. procedure ROTATEpZ(k :byte);
  1618. var i   :byte;
  1619. begin
  1620.    with VObj[k] do begin
  1621.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1622.          X1[i]:=X1[i]*FactorCos-Y1[i]*FactorSin;
  1623.          Y1[i]:=X1[i]*FactorSin+Y1[i]*FactorCos;
  1624.       end;
  1625.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1626.          X2[i]:=X2[i]*FactorCos-Y2[i]*FactorSin;
  1627.          Y2[i]:=X2[i]*FactorSin+Y2[i]*FactorCos;
  1628.       end;
  1629.    end;
  1630. end;
  1631.  
  1632.  
  1633. procedure ROTATEnX(k :byte);
  1634. var i   :byte;
  1635. begin
  1636.    with VObj[k] do begin
  1637.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1638.          Y1[i]:=Y1[i]*FactorMCos-Z1[i]*FactorMSin;
  1639.          Z1[i]:=Y1[i]*FactorMSin+Z1[i]*FactorMCos;
  1640.       end;
  1641.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1642.          Y2[i]:=Y2[i]*FactorMCos-Z2[i]*FactorMSin;
  1643.          Z2[i]:=Y2[i]*FactorMSin+Z2[i]*FactorMCos;
  1644.       end;
  1645.    end;
  1646. end;
  1647.  
  1648.  
  1649. procedure ROTATEnY(k :byte);
  1650. var i   :byte;
  1651. begin
  1652.    with VObj[k] do begin
  1653.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1654.          X1[i]:=X1[i]*FactorMCos-Z1[i]*FactorMSin;
  1655.          Z1[i]:=Z1[i]*FactorMCos+X1[i]*FactorMSin;
  1656.       end;
  1657.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1658.          X2[i]:=X2[i]*FactorMCos-Z2[i]*FactorMSin;
  1659.          Z2[i]:=Z2[i]*FactorMCos+X2[i]*FactorMSin;
  1660.       end;
  1661.    end;
  1662. end;
  1663.  
  1664.  
  1665. procedure ROTATEnZ(k :byte);
  1666. var i   :byte;
  1667. begin
  1668.    with VObj[k] do begin
  1669.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1670.          X1[i]:=X1[i]*FactorMCos-Y1[i]*FactorMSin;
  1671.          Y1[i]:=X1[i]*FactorMSin+Y1[i]*FactorMCos;
  1672.       end;
  1673.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1674.          X2[i]:=X2[i]*FactorMCos-Y2[i]*FactorMSin;
  1675.          Y2[i]:=X2[i]*FactorMSin+Y2[i]*FactorMCos;
  1676.       end;
  1677.    end;
  1678. end;
  1679.  
  1680.  
  1681. procedure FLY(k :byte);
  1682. var i,j   :integer;
  1683. begin
  1684.    with VObj[k] do begin
  1685.       if Size1=0 then exit else for i:=1 to Size1 do begin
  1686.          X1[i]:=X1[i]*Factor;
  1687.          Y1[i]:=Y1[i]*Factor;
  1688.          Z1[i]:=Z1[i]*Factor;
  1689.          if not (round(PosX-X1[i]) in [0..639])
  1690.          or not (round(PosY-Y1[i]) in [75..434]) then begin
  1691.             Size1:=0; exit;
  1692.          end;
  1693.       end;
  1694.       if Size2=0 then exit else for i:=1 to Size2 do begin
  1695.          X2[i]:=X2[i]*Factor;
  1696.          Y2[i]:=Y2[i]*Factor;
  1697.          Z2[i]:=Z2[i]*Factor;
  1698.          if not (round(PosX-X2[i]) in [0..639])
  1699.          or not (round(PosY-Y2[i]) in [75..434]) then begin
  1700.             Size1:=0; exit;
  1701.          end;
  1702.       end;
  1703.    end;
  1704. end;
  1705.  
  1706.  
  1707. procedure GREATEFFECT(Objects :byte);
  1708.  
  1709. var Ctr         :word;
  1710.  
  1711. begin
  1712.    WaitTOF;
  1713.    Factor:=0; Ctr:=0;
  1714.    repeat
  1715.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  1716.       Factor:=Factor+0.02; Ctr:=Ctr+1;
  1717.       for i:=1 to 31 do
  1718.        SetRGB32(^MyScreen[AScr]^.ViewPort,i,round(Colors[i].R*Factor)*$1000000,round(Colors[i].G*Factor)*$1000000,round(Colors[i].B*Factor)*$1000000);
  1719.       if Ctr=11 then begin
  1720.          SPAddrD^:=SMemA[2];         SPAddrC^:=SMemA[2]+SMemL[2] div 2;
  1721.          SPVolD^:=64;                SPVolC^:=64;
  1722.          SPFreqD^:=380;              SPFreqC^:=380;
  1723.          SPLengthD^:=SMemL[2] div 4; SPLengthC^:=SMemL[2] div 4;
  1724.          DMACON_WRITE^:=$800C;
  1725.       end else if Ctr=12 then begin
  1726.          SPLengthD^:=1;              SPLengthC^:=1;
  1727.       end;
  1728.    until Factor>=1;
  1729.    SetRGB4(^MyScreen[3-AScr]^.ViewPort,0,8,8,10);
  1730.    WaitTOF;
  1731.    WaitTOF;
  1732.    SetRGB4(^MyScreen[3-AScr]^.ViewPort,0,0,0,0);
  1733.    for i:=1 to 31 do SetRGB32(^MyScreen[3-AScr]^.ViewPort,i,Colors[i].R*$1000000,Colors[i].G*$1000000,Colors[i].B*$1000000);
  1734.    delay(50);
  1735.    repeat
  1736.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  1737.       Factor:=Factor-0.02;
  1738.       SetRGB32(^MyScreen[AScr]^.ViewPort,31,round(Colors[31].R*Factor)*$1000000,round(Colors[31].G*Factor)*$1000000,round(Colors[31].B*Factor)*$1000000);
  1739.    until Factor<=0;
  1740.    for i:=1 to Objects do with VObj[i] do begin
  1741.       for j:=1 to Size1 do PosX:=round(PosX+X1[j]); PosX:=round(PosX/Size1);
  1742.       for j:=1 to Size1 do PosY:=round(PosY+Y1[j]); PosY:=235+round(PosY/Size1);
  1743.       for j:=1 to Size1 do X1[j]:=succ(PosX)-X1[j];
  1744.       for j:=1 to Size1 do Y1[j]:=succ(PosY)-Y1[j]-235;
  1745.       if Size2>0 then for j:=1 to Size2 do X2[j]:=succ(PosX)-X2[j];
  1746.       if Size2>0 then for j:=1 to Size2 do Y2[j]:=succ(PosY)-Y2[j]-235;
  1747.    end;
  1748.    SPAddrD^:=SMemA[3];         SPAddrC^:=SMemA[3]+SMemL[3] div 2;
  1749.    SPVolD^:=64;                SPVolC^:=64;
  1750.    SPFreqD^:=550;              SPFreqC^:=550;
  1751.    SPLengthD^:=SMemL[3] div 4; SPLengthC^:=SMemL[3] div 4;
  1752.    DMACON_WRITE^:=$800C;
  1753.    Factor:=1.0025;
  1754.    for i:=1 to 29 do begin
  1755.       Factor:=Factor+0.004;
  1756.       if i>1 then begin
  1757.          SetAPen(^MyScreen[AScr]^.RastPort,0);
  1758.          RectFill(^MyScreen[AScr]^.RastPort,0,150,639,330);    {75..434}
  1759.       end else for j:=2 to 30 do SetRGB32(^MyScreen[AScr]^.ViewPort,j,Colors[j].R*$A00000,Colors[j].G*$A00000,Colors[j].B*$A00000);
  1760.       if i>16 then VObj[succ(random(13))].Size1:=0;
  1761.  
  1762.       for j:=1 to Objects do with VObj[j] do begin
  1763.          if Size1>0 then begin
  1764.             if j>2 then begin
  1765.                SetAPen(^MyScreen[AScr]^.RastPort,0);
  1766.                if Size2>4 then begin
  1767.                   AreaMove(^MyScreen[AScr]^.RastPort,round(PosX-X2[4]),round(PosY-Y2[4]));
  1768.                   for k:=5 to 6 do AreaDraw(^MyScreen[AScr]^.RastPort,round(PosX-X2[k]),round(PosY-Y2[k]));
  1769.                end;
  1770.                AreaMove(^MyScreen[AScr]^.RastPort,round(PosX-X1[4]),round(PosY-Y1[4]));
  1771.                for k:=5 to 6 do AreaDraw(^MyScreen[AScr]^.RastPort,round(PosX-X1[k]),round(PosY-Y1[k]));
  1772.                AreaEnd(^MyScreen[AScr]^.RastPort);
  1773.             end;
  1774.             SetAPen(^MyScreen[AScr]^.RastPort,1);
  1775.             AreaMove(^MyScreen[AScr]^.RastPort,round(PosX-X1[1]),round(PosY-Y1[1]));
  1776.             for k:=2 to Size1 do AreaDraw(^MyScreen[AScr]^.RastPort,round(PosX-X1[k]),round(PosY-Y1[k]));
  1777.             AreaEnd(^MyScreen[AScr]^.RastPort);
  1778.             if Size2>0 then begin
  1779.                AreaMove(^MyScreen[AScr]^.RastPort,round(PosX-X2[1]),round(PosY-Y2[1]));
  1780.                for k:=2 to Size2 do AreaDraw(^MyScreen[AScr]^.RastPort,round(PosX-X2[k]),round(PosY-Y2[k]));
  1781.                AreaEnd(^MyScreen[AScr]^.RastPort);
  1782.             end;
  1783.          end;
  1784.          if not (Flag and ROTATE_PX=0) then ROTATEpX(j);
  1785.          if not (Flag and ROTATE_PY=0) then ROTATEpY(j);
  1786.          if not (Flag and ROTATE_PZ=0) then ROTATEpZ(j);
  1787.          if not (Flag and ROTATE_NX=0) then ROTATEnX(j);
  1788.          if not (Flag and ROTATE_NY=0) then ROTATEnY(j);
  1789.          if not (Flag and ROTATE_NZ=0) then ROTATEnZ(j);
  1790.          FLY(j);
  1791.       end;
  1792.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  1793.       if i=1 then begin
  1794.          SPLengthD^:=1; SPLengthC^:=1;
  1795.       end;
  1796.    end;
  1797.    for i:=1 to 2 do begin
  1798.       SetAPen(^MyScreen[AScr]^.RastPort,0);
  1799.       RectFill(^MyScreen[AScr]^.RastPort,0,75,639,434);
  1800.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  1801.    end;
  1802.    DMACON_WRITE^:=$000C;
  1803. end;
  1804.  
  1805.  
  1806. function LOADSOUNDS:boolean;
  1807.  
  1808. var i           :byte;
  1809. var SSize       :long;
  1810.  
  1811. begin
  1812.    LOADSOUNDS:=false;
  1813.    INITCHANNELS;
  1814.    for i:=1 to 3 do begin
  1815.       s:=PathStr[8]+'Snd'+intstr(i)+'.RAW';
  1816.       FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  1817.       if FHandle<>0 then begin
  1818.          SSize:=DosSeek(FHandle,0,OFFSET_END);
  1819.          SSize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  1820.          SMemL[i]:=SSize;
  1821.          SMemA[i]:=AllocMem(SSize,MEMF_CHIP+MEMF_CLEAR);
  1822.          if SMemA[i]=0 then exit;
  1823.          l:=DosRead(FHandle,ptr(SMemA[i]),SMemL[i]);
  1824.          DosClose(FHandle);
  1825.       end else exit;
  1826.    end;
  1827.    LOADSOUNDS:=true;
  1828. end;
  1829.  
  1830.  
  1831. begin { MAININTRO }
  1832.    i:=SetTaskPri(FindTask(NIL),120);
  1833.    TMPtr:=0; AScr:=1; MyRastPtr:=NIL;
  1834.    for i:=1 to 2 do MyScreen[i]:=NIL;
  1835.    for i:=1 to 3 do SMemA[i]:=0;
  1836.    for i:=0 to 1 do IMemA[i]:=0;
  1837.    if not LOADSOUNDS then begin
  1838.       INTROEXIT;
  1839.       exit;
  1840.    end;
  1841.    for i:=1 to 2 do begin
  1842.       MyScreen[i]:=OPENCINEMA(5);
  1843.       if MyScreen[i]=NIL then begin
  1844.          INTROEXIT;
  1845.          exit;
  1846.       end;
  1847.    end;
  1848.    IMemL[0]:=73500;
  1849.    IMemA[0]:=AllocMem(IMemL[0],MEMF_CHIP);
  1850.    if IMemA[0]=0 then begin
  1851.       INTROEXIT;
  1852.       exit;
  1853.    end;
  1854.     IntroBitMap:=ITBitMap(80,183,1,5,0,ptr(IMemA[0]),ptr(IMemA[0]+14640),
  1855.                          ptr(IMemA[0]+29280),ptr(IMemA[0]+43920),
  1856.                          ptr(IMemA[0]+58560),NIL,NIL,NIL,IMemA[0],IMemL[0]);
  1857.    s:=PathStr[8]+'Frame0.pal';
  1858.    l:=SETCOLOR(MyScreen[1]^,s);
  1859.    l:=SETCOLOR(MyScreen[2]^,s);
  1860.    s:=PathStr[8]+'Frame0.img';
  1861.    if not RAWLOADIMAGE(s,0,0,640,183,5,IntroBitMap) then begin
  1862.       INTROEXIT;
  1863.       exit;
  1864.    end;
  1865.    for i:=1 to 8 do begin
  1866.       BltBitMapRastPort(^IntroBitMap,0,0,^MyScreen[3-AScr]^.RastPort,640-i*5,340,i*5,90,192);
  1867.       AScr:=3-Ascr; ScreenToFront(MyScreen[Ascr]);
  1868.    end;
  1869.    l:=590;
  1870.    repeat
  1871.       l:=l-5;
  1872.       BltBitMapRastPort(^IntroBitMap,0,0,^MyScreen[3-AScr]^.RastPort,l,340,49,90,192);
  1873.       BltBitMapRastPort(^IntroBitMap,41,0,^MyScreen[3-Ascr]^.RastPort,l+49,340,5,90,192);
  1874.       AScr:=3-Ascr; ScreenToFront(MyScreen[Ascr]);
  1875.       if LData^ and 64=0 then begin
  1876.          INTROEXIT; exit;
  1877.       end;
  1878.    until l<=10;
  1879.    ClipBlit(^MyScreen[Ascr]^.RastPort,10,340,^MyScreen[3-Ascr]^.RastPort,10,340,50,90,192);
  1880.    for i:=1 to 9 do begin
  1881.       BltBitMapRastPort(^IntroBitMap,50,0,^MyScreen[3-AScr]^.RastPort,640-i*5,340,i*5,90,192);
  1882.       AScr:=3-Ascr; ScreenToFront(MyScreen[Ascr]);
  1883.    end;
  1884.    l:=595;
  1885.    SetAPen(^MyScreen[AScr]^.RastPort,0); SetAPen(^MyScreen[3-AScr]^.RastPort,0);
  1886.    repeat
  1887.       l:=l-5;
  1888.       BltBitMapRastPort(^IntroBitMap,50,0,^MyScreen[3-AScr]^.RastPort,l,340,41,90,192);
  1889.       RectFill(^MyScreen[3-AScr]^.RastPort,l+41,340,l+50,430);
  1890.       AScr:=3-Ascr; ScreenToFront(MyScreen[Ascr]);
  1891.       if LData^ and 64=0 then begin
  1892.          INTROEXIT; exit;
  1893.       end;
  1894.    until l<=60;
  1895.    ClipBlit(^MyScreen[AScr]^.RastPort,10,340,^MyScreen[3-Ascr]^.RastPort,10,340,150,90,192);
  1896.    delay(5);
  1897.    for i:=1 to 2 do begin
  1898.       BltBitMapRastPort(^IntroBitMap,0,0,^MyScreen[3-AScr]^.RastPort,10,340,616,91,192);
  1899.       AScr:=3-Ascr;
  1900.       ScreenToFront(MyScreen[Ascr]);
  1901.    end;
  1902.    if LData^ and 64=0 then begin
  1903.       INTROEXIT; exit;
  1904.    end;
  1905.    delay(15);
  1906.    BltBitMapRastPort(^IntroBitMap,0,90,^MyScreen[3-AScr]^.RastPort,10,337,98,91,192);
  1907.    AScr:=3-Ascr;
  1908.    ScreenToFront(MyScreen[Ascr]);
  1909.    DMACON_WRITE^:=$000F;
  1910.    delay(15);
  1911.    SPAddrA^:=SMemA[1];         SPAddrB^:=SMemA[1]+SMemL[1] div 2;
  1912.    SPVolA^:=0;                 SPVolB^:=0;
  1913.    SPFreqA^:=856;              SPFreqB^:=856;
  1914.    SPLengthA^:=SMemL[1] div 4; SPLengthB^:=SMemL[1] div 4;
  1915.  
  1916.    SPAddrD^:=SMemA[2];         SPAddrC^:=SMemA[2]+SMemL[2] div 2;
  1917.    SPVolD^:=64;                SPVolC^:=64;
  1918.    SPFreqD^:=380;              SPFreqC^:=380;
  1919.    SPLengthD^:=1;              SPLengthC^:=1;
  1920.  
  1921.    DMACON_WRITE^:=$8003;
  1922.    for btx:=1 to 64 do begin
  1923.       SPVolA^:=btx;
  1924.       SPVolB^:=btx;
  1925.       WaitTOF;
  1926.    end;
  1927.    delay(25);
  1928.    FactorSin:=sin(0.04);   FactorCos:=cos(0.03);
  1929.    FactorMSin:=sin(-0.05); FactorMCos:=cos(-0.02);
  1930.    for i:=1 to 2 do begin
  1931.       SetAPen(^MyScreen[3-Ascr]^.RastPort,0);
  1932.       RectFill(^MyScreen[3-Ascr]^.RastPort,0,335,640,430);
  1933.       AScr:=3-Ascr;
  1934.       ScreenToFront(MyScreen[Ascr]);
  1935.    end;
  1936.  
  1937.    MyRastPtr:=AllocRaster(640,360);
  1938.    if MyRastPtr=NIL then begin
  1939.       INTROEXIT;
  1940.       exit;
  1941.    end;
  1942.    InitTmpRas(^MyTmpRas,MyRastPtr,21000);
  1943.    InitArea(^MyAI,ptr(IMemA[0]),200);
  1944.    MyScreen[1]^.RastPort.TmpRas:=^MyTmpRas; MyScreen[2]^.RastPort.TmpRas:=^MyTmpRas;
  1945.    MyScreen[1]^.RastPort.AreaInfo:=^MyAI;   MyScreen[2]^.RastPort.AreaInfo:=^MyAI;
  1946.  
  1947. {*****************************************************************************}
  1948.  
  1949.    s:=PathStr[8]+'Frame1.pal';         { TOUCHBYTE SOWFTWARE PRESENTS }
  1950.    SETDARKCOLOR(s);
  1951.    s:=PathStr[8]+'Frame1.img';
  1952.    if not DISPLAYIMAGE(s,0,235,640,37,5,MyScreen[AScr]^,0) then begin end;
  1953.    WRITE(320,285,31,16,MyScreen[AScr]^,5,'PRESENTS');
  1954.    ClipBlit(^MyScreen[AScr]^.RastPort,0,235,^MyScreen[3-AScr]^.RastPort,0,235,640,75,192);
  1955.    VObj[1]:=VectorObj(0,0,ROTATE_PY+ROTATE_PX,
  1956.       { T }           6,4,CArr(38,9,9,9,9,38),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1957.                           CArr(18,18,18,18,0,0),CArr(11,36,36,11,0,0),CArr(1,1,3,3,0,0));
  1958.    VObj[2]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  1959.       { U }           6,6,CArr(91,80,80,80,80,91),CArr(1,1,26,26,1,1),CArr(1,1,1,3,3,3),
  1960.                           CArr(111,100,100,100,100,111),CArr(1,1,24,24,1,1),CArr(1,1,1,3,3,3));
  1961.    VObj[3]:=VectorObj(0,0,ROTATE_PY+ROTATE_NZ,
  1962.       { H }           6,6,CArr(163,152,152,152,152,163),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  1963.                           CArr(184,173,173,173,173,184),CArr(2,2,12,12,2,2),CArr(1,1,1,3,3,3));
  1964.    VObj[4]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  1965.       { B }           6,6,CArr(209,187,187,187,187,209),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1966.                           CArr(205,187,187,187,187,205),CArr(15,15,36,36,15,15),CArr(1,1,1,3,3,3));
  1967.    VObj[5]:=VectorObj(0,0,ROTATE_PZ+ROTATE_NX,
  1968.       { Y }           6,6,CArr(229,217,229,229,217,229),CArr(2,2,19,19,2,2),CArr(1,1,1,3,3,3),
  1969.                           CArr(254,242,236,236,242,254),CArr(2,2,12,12,2,2),CArr(1,1,1,3,3,3));
  1970.    VObj[6]:=VectorObj(0,0,ROTATE_NX+ROTATE_NY,
  1971.       { T }           6,4,CArr(285,256,256,256,256,285),CArr(2,2,9,9,1,1),CArr(1,1,1,3,3,3),
  1972.                           CArr(266,266,266,266,0,0),CArr(11,36,36,11,0,0),CArr(1,1,3,3,0,0));
  1973.    VObj[7]:=VectorObj(0,0,ROTATE_PX+ROTATE_PY,
  1974.       { E }           6,6,CArr(318,289,289,289,289,318),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1975.                           CArr(315,289,289,289,289,315),CArr(14,14,36,36,14,14),CArr(1,1,1,3,3,3));
  1976.    VObj[8]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  1977.       { F }           6,6,CArr(440,410,410,410,410,440),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1978.                           CArr(437,410,410,410,410,437),CArr(14,14,36,36,14,14),CArr(1,1,1,3,3,3));
  1979.    VObj[9]:=VectorObj(0,0,ROTATE_NZ+ROTATE_NY,
  1980.       { T }           6,4,CArr(472,443,443,443,443,472),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1981.                           CArr(452,452,452,452,0,0),CArr(11,36,36,11,0,0),CArr(1,1,3,3,0,0));
  1982.    VObj[10]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  1983.       { W }            6,6,CArr(486,475,486,486,475,486),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  1984.                            CArr(506,497,492,492,497,506),CArr(2,2,16,16,2,2),CArr(1,1,1,3,3,3));
  1985.    VObj[11]:=VectorObj(0,0,ROTATE_PX+ROTATE_PY,
  1986.       { A }            6,0,CArr(547,536,521,521,536,547),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  1987.                           CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  1988.    VObj[12]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  1989.       { R }            6,6,CArr(589,565,565,565,565,589),CArr(3,2,10,10,2,3),CArr(1,1,1,3,3,3),
  1990.                            CArr(576,565,565,565,565,576),CArr(16,16,36,36,16,16),CArr(1,1,1,3,3,3));
  1991.    VObj[13]:=VectorObj(0,0,ROTATE_NX+ROTATE_NY,
  1992.       { E }            6,6,CArr(630,601,601,601,601,630),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  1993.                            CArr(627,601,601,601,601,627),CArr(14,14,36,36,14,14),CArr(1,1,1,3,3,3));
  1994.  
  1995.    if LData^ and 64=0 then begin
  1996.       INTROEXIT; exit;
  1997.    end;
  1998.    GREATEFFECT(13);
  1999.    if LData^ and 64=0 then begin
  2000.       INTROEXIT; exit;
  2001.    end;
  2002.  
  2003. {*****************************************************************************}
  2004.  
  2005.    s:=PathStr[8]+'Frame2.pal';         { A VIRTUAL WORLDS PRODUCTION }
  2006.    SETDARKCOLOR(s);
  2007.    s:=PathStr[8]+'Frame2.img';
  2008.    if not DISPLAYIMAGE(s,0,235,640,37,5,MyScreen[AScr]^,0) then begin end;
  2009.    WRITE(320,205,31,16,MyScreen[AScr]^,5,'A');
  2010.    WRITE(320,285,31,16,MyScreen[AScr]^,5,'PRODUCTION');
  2011.    ClipBlit(^MyScreen[AScr]^.RastPort,0,200,^MyScreen[3-AScr]^.RastPort,0,200,640,150,192);
  2012.    VObj[1]:=VectorObj(0,0,ROTATE_PY+ROTATE_PX,
  2013.       { V }           6,6,CArr(98,86,101,101,86,98),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2014.                           CArr(126,114,106,106,114,126),CArr(2,2,23,23,2,2),CArr(1,1,1,3,3,3));
  2015.    VObj[2]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  2016.       { I }           6,0,CArr(140,129,129,129,129,140),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2017.                           CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2018.    VObj[3]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2019.       { R }           6,6,CArr(167,143,143,143,143,167),CArr(3,2,10,10,2,3),CArr(1,1,1,3,3,3),
  2020.                           CArr(154,143,143,143,143,154),CArr(16,16,36,36,16,16),CArr(1,1,1,3,3,3));
  2021.    VObj[4]:=VectorObj(0,0,ROTATE_PY+ROTATE_NZ,
  2022.       { T }           6,4,CArr(206,177,177,177,177,206),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  2023.                           CArr(186,186,186,186,0,0),CArr(11,36,36,11,0,0),CArr(1,1,3,3,0,0));
  2024.    VObj[5]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2025.       { U }           6,6,CArr(220,209,209,209,209,220),CArr(2,2,27,27,2,2),CArr(1,1,1,3,3,3),
  2026.                           CArr(240,229,229,229,229,240),CArr(2,2,25,25,2,2),CArr(1,1,1,3,3,3));
  2027.    VObj[6]:=VectorObj(0,0,ROTATE_PZ+ROTATE_NX,
  2028.       { A }           6,0,CArr(266,255,240,240,255,266),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2029.                           CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2030.    VObj[7]:=VectorObj(0,0,ROTATE_NX+ROTATE_NY,
  2031.       { L }           6,4,CArr(295,284,284,284,284,295),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2032.                           CArr(311,296,296,311,0,0),CArr(26,26,26,26,0,0),CArr(1,1,3,3,0,0));
  2033.    VObj[8]:=VectorObj(0,0,ROTATE_PX+ROTATE_PY,
  2034.       { W }           6,6,CArr(335,324,335,335,324,335),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2035.                           CArr(355,346,341,341,346,355),CArr(2,2,16,16,2,2),CArr(1,1,1,3,3,3));
  2036.    VObj[9]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2037.       { R }           6,6,CArr(441,417,417,417,417,441),CArr(3,2,10,10,2,3),CArr(1,1,1,3,3,3),
  2038.                           CArr(428,417,417,417,417,428),CArr(16,16,36,36,16,16),CArr(1,1,1,3,3,3));
  2039.    VObj[10]:=VectorObj(0,0,ROTATE_NZ+ROTATE_NY,
  2040.       { L }            6,4,CArr(464,453,453,453,453,464),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2041.                            CArr(480,465,465,480,0,0),CArr(26,26,26,26,0,0),CArr(1,1,3,3,0,0));
  2042.    VObj[11]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  2043.       { D }            6,0,CArr(505,483,483,483,483,505),CArr(3,2,36,36,2,3),CArr(1,1,1,3,3,3),
  2044.                            CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2045.    if LData^ and 64=0 then begin
  2046.       INTROEXIT; exit;
  2047.    end;
  2048.    GREATEFFECT(11);
  2049.    if LData^ and 64=0 then begin
  2050.       INTROEXIT; exit;
  2051.    end;
  2052. {*****************************************************************************}
  2053.  
  2054.    s:=PathStr[8]+'Frame3.pal';         { IMPERIUM TERRANUM }
  2055.    SETDARKCOLOR(s);
  2056.    s:=PathStr[8]+'Frame3.img';
  2057.    if not DISPLAYIMAGE(s,0,235,640,37,5,MyScreen[AScr]^,0) then begin end;
  2058.    WRITE(320,285,31,16,MyScreen[AScr]^,5,'A TRIBUTE TO STAR TREK');
  2059.    ClipBlit(^MyScreen[AScr]^.RastPort,0,235,^MyScreen[3-AScr]^.RastPort,0,235,640,100,192);
  2060.    VObj[1]:=VectorObj(0,0,ROTATE_PY+ROTATE_PX,
  2061.       { I }           6,6,CArr(48,37,37,37,37,48),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2062.                           CArr(95,84,73,73,84,95),CArr(2,2,18,18,2,2),CArr(1,1,1,3,3,3));
  2063.    VObj[2]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  2064.       { M }           6,0,CArr(62,51,51,51,51,62),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2065.                           CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2066.    VObj[3]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2067.       { E }           6,6,CArr(161,132,132,132,132,161),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  2068.                           CArr(158,132,132,132,132,158),CArr(14,14,36,36,14,14),CArr(1,1,1,3,3,3));
  2069.    VObj[4]:=VectorObj(0,0,ROTATE_PY+ROTATE_NZ,
  2070.       { I }           6,0,CArr(211,200,200,200,200,211),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2071.                           CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2072.    VObj[5]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2073.       { U }           6,6,CArr(225,214,214,214,214,225),CArr(2,2,27,27,2,2),CArr(1,1,1,3,3,3),
  2074.                           CArr(245,234,234,234,234,245),CArr(2,2,25,25,2,2),CArr(1,1,1,3,3,3));
  2075.    VObj[6]:=VectorObj(0,0,ROTATE_PZ+ROTATE_NX,
  2076.       { M }           6,6,CArr(259,248,248,248,248,259),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2077.                           CArr(292,281,270,270,281,292),CArr(2,2,18,18,2,2),CArr(1,1,1,3,3,3));
  2078.    VObj[7]:=VectorObj(0,0,ROTATE_NX+ROTATE_NY,
  2079.       { T }           6,4,CArr(338,309,309,309,309,338),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  2080.                           CArr(318,318,318,318,0,0),CArr(21,36,36,11,0,0),CArr(1,1,3,3,0,0));
  2081.    VObj[8]:=VectorObj(0,0,ROTATE_PX+ROTATE_PY,
  2082.       { E }           6,6,CArr(370,341,341,341,341,370),CArr(2,2,10,10,2,2),CArr(1,1,1,3,3,3),
  2083.                           CArr(367,341,341,341,341,367),CArr(14,14,36,36,14,14),CArr(1,1,1,3,3,3));
  2084.    VObj[9]:=VectorObj(0,0,ROTATE_NX+ROTATE_PZ,
  2085.       { R }           6,6,CArr(433,409,409,409,409,433),CArr(3,2,10,10,2,3),CArr(1,1,1,3,3,3),
  2086.                           CArr(420,409,409,409,409,420),CArr(16,16,36,36,16,16),CArr(1,1,1,3,3,3));
  2087.    VObj[10]:=VectorObj(0,0,ROTATE_NZ+ROTATE_NY,
  2088.       { A }            6,0,CArr(471,460,445,445,460,471),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2089.                            CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0),CArr(0,0,0,0,0,0));
  2090.    VObj[11]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  2091.       { N }            6,6,CArr(500,489,489,489,489,500),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2092.                            CArr(521,510,510,510,510,521),CArr(2,2,17,17,2,2),CArr(1,1,1,3,3,3));
  2093.    VObj[12]:=VectorObj(0,0,ROTATE_PX+ROTATE_PZ,
  2094.       { M }            6,6,CArr(569,558,558,558,558,569),CArr(2,2,36,36,2,2),CArr(1,1,1,3,3,3),
  2095.                            CArr(602,591,580,580,591,602),CArr(2,2,18,18,2,2),CArr(1,1,1,3,3,3));
  2096.    if LData^ and 64=0 then begin
  2097.       INTROEXIT; exit;
  2098.    end;
  2099.    GREATEFFECT(12);
  2100.    if LData^ and 64=0 then begin
  2101.       INTROEXIT; exit;
  2102.    end;
  2103.    FreeRaster(MyRastPtr,640,360); MyRastPtr:=NIL;
  2104.    for i:=1 to 2 do if MyScreen[i]<>NIL then begin
  2105.       CloseScreen(MyScreen[i]); MyScreen[i]:=NIL;
  2106.    end;
  2107.    FreeMem(IMemA[0],IMemL[0]); IMemA[0]:=0;
  2108.  
  2109.    for i:=1 to 2 do begin
  2110.       MyScreen[i]:=OPENCINEMA(7);
  2111.       if MyScreen[i]=NIL then begin
  2112.          INTROEXIT; exit;
  2113.       end;
  2114.    end;
  2115.    IMemL[0]:=201856; IMemL[1]:=21000;
  2116.    for i:=0 to 1 do begin
  2117.       IMemA[i]:=AllocMem(IMemL[i],MEMF_CHIP);
  2118.       if IMemA[i]=0 then begin
  2119.          INTROEXIT;
  2120.          exit;
  2121.       end;
  2122.    end;
  2123.    SPAddrD^:=SMemA[2]+6500;            SPAddrC^:=SMemA[2]+(SMemL[2] div 2)+6500;
  2124.    SPVolD^:=64;                        SPVolC^:=64;
  2125.    SPFreqD^:=380;                      SPFreqC^:=380;
  2126.    SPLengthD^:=(SMemL[2]-13000) div 4; SPLengthC^:=(SMemL[2]-13000) div 4;
  2127.    DMACON_WRITE^:=$800C;
  2128.    WaitTOF;
  2129.    SPLengthD^:=1; SPLengthC^:=1;
  2130.    btx:=255;
  2131.    repeat
  2132.       SetRGB32(^MyScreen[2]^.ViewPort,0,btx*$1000000,btx*$1000000,btx*$1000000);
  2133.       btx:=btx-5;
  2134.       WaitTOF;
  2135.    until btx<=10;
  2136.    SetRGB32(^MyScreen[2]^.ViewPort,0,0,0,0);
  2137.    DMACON_WRITE^:=$000C;
  2138.    if LData^ and 64=0 then begin
  2139.       INTROEXIT; exit;
  2140.    end;
  2141.    s:=PathStr[8]+'ST/MOD.Intro';
  2142.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  2143.    if FHandle<>0 then DosClose(FHandle);
  2144.    TMPTR:=LoadModule(s);
  2145.    PlayModule(TMPTR);
  2146.    s:=PathStr[8]+'Frame4.pal';
  2147.    SETDARKCOLOR(s);
  2148.    s:=PathStr[8]+'Frame4.img';
  2149.    if not DISPLAYIMAGE(s,0,75,640,360,7,MyScreen[2]^,0) then begin end;
  2150.    ClipBlit(^MyScreen[2]^.RastPort,0,75,^MyScreen[1]^.RastPort,0,75,640,360,192);
  2151.  
  2152.    s:=PathStr[8]+'Frame5.img';
  2153.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  2154.    if FHandle<>0 then begin
  2155.       ISize:=DosSeek(FHandle,0,OFFSET_END);
  2156.       ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  2157.       l:=DosRead(FHandle,ptr(IMemA[0]+IMemL[0]-ISize-250),ISize);
  2158.       UNPACK(IMemA[0],IMemA[0]+IMemL[0]-ISize-250,20160,0);
  2159.       DosClose(FHandle);
  2160.    end;
  2161.    MyPlanePtr:=PlaneArr(ptr(IMemA[0]),      ptr(IMemA[0]+2880), ptr(IMemA[0]+5760),
  2162.                         ptr(IMemA[0]+8640), ptr(IMemA[0]+11520),ptr(IMemA[0]+14400),
  2163.                         ptr(IMemA[0]+17280),NIL);
  2164.    MyBitMap:=BitMap(20,144,1,7,0,MyPlanePtr);
  2165.  
  2166.    Factor:=0;
  2167.    repeat
  2168.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2169.       Factor:=Factor+0.05;
  2170.       for i:=1 to 127 do
  2171.        SetRGB32(^MyScreen[AScr]^.ViewPort,i,round(Colors[i].R*Factor)*$1000000,round(Colors[i].G*Factor)*$1000000,round(Colors[i].B*Factor)*$1000000);
  2172.    until Factor>=1;
  2173.    for i:=1 to 127 do SetRGB32(^MyScreen[3-AScr]^.ViewPort,i,Colors[i].R*$1000000,Colors[i].G*$1000000,Colors[i].B*$1000000);
  2174.    ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,75,639,434);
  2175.    for i:=1 to 6 do begin
  2176.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2177.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-8,0,75,639,434);
  2178.       ClipBlit(^MyScreen[AScr]^.RastPort,0,270,^MyScreen[AScr]^.RastPort,0,75,640,8,192);
  2179.    end;
  2180.    for i:=1 to 35 do begin
  2181.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2182.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-8,0,75,639,434);
  2183.       ClipBlit(^MyScreen[AScr]^.RastPort,0,270,^MyScreen[AScr]^.RastPort,0,75,640,8,192);
  2184.       BltBitMapRastPort(^MyBitMap,0,140-i*4,^MyScreen[AScr]^.RastPort,380,75,160,8,192);
  2185.    end;
  2186.    ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2187.    ScrollRaster(^MyScreen[AScr]^.RastPort,0,-8,0,75,639,434);
  2188.    ClipBlit(^MyScreen[AScr]^.RastPort,0,270,^MyScreen[AScr]^.RastPort,0,75,640,8,192);
  2189.    BltBitMapRastPort(^MyBitMap,0,0,^MyScreen[AScr]^.RastPort,380,79,160,4,192);
  2190.    for i:=1 to 14 do begin
  2191.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2192.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-8,0,75,639,434);
  2193.       ClipBlit(^MyScreen[AScr]^.RastPort,0,270,^MyScreen[AScr]^.RastPort,0,75,640,8,192);
  2194.    end;
  2195.    delay(10);
  2196.    if LData^ and 64=0 then begin
  2197.       INTROEXIT; exit;
  2198.    end;
  2199.    RECT(MyScreen[AScr]^,0,0,75,639,434);
  2200.    ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2201.    RECT(MyScreen[AScr]^,0,0,75,639,434);
  2202.    s:=PathStr[8]+'Frame6.pal';
  2203.    l:=SETCOLOR(MyScreen[AScr]^,s);                  l:=SETCOLOR(MyScreen[3-AScr]^,s);
  2204.    SetRGB4(^MyScreen[AScr]^.ViewPort,127,9,9,11);   SetRGB4(^MyScreen[3-AScr]^.ViewPort,127,9,9,11);
  2205.    SetRGB4(^MyScreen[AScr]^.ViewPort,126,11,11,15); SetRGB4(^MyScreen[3-AScr]^.ViewPort,126,11,11,15);
  2206.    SetRGB4(^MyScreen[AScr]^.ViewPort,125,15,0,15);  SetRGB4(^MyScreen[3-AScr]^.ViewPort,125,15,0,15);
  2207.    SetRGB4(^MyScreen[AScr]^.ViewPort,124,13,0,0);   SetRGB4(^MyScreen[3-AScr]^.ViewPort,124,15,2,2);
  2208.    SetRGB4(^MyScreen[AScr]^.ViewPort,123,14,14,15); SetRGB4(^MyScreen[3-AScr]^.ViewPort,123,14,14,15);
  2209.  
  2210.    s:=PathStr[8]+'Frame6.img';
  2211.    if not DISPLAYIMAGE(s,0,75,640,360,7,MyScreen[AScr]^,0) then begin end;
  2212.    MyPlanePtr:=PlaneArr(ptr(IMemA[0]),       ptr(IMemA[0]+28800), ptr(IMemA[0]+57600),
  2213.                         ptr(IMemA[0]+86400), ptr(IMemA[0]+115200),ptr(IMemA[0]+144000),
  2214.                         ptr(IMemA[0]+172800),NIL);
  2215.    MyBitMap:=BitMap(80,360,1,7,0,MyPlanePtr);
  2216.    BltBitMapRastPort(^MyBitMap,0,0,^MyScreen[3-AScr]^.RastPort,0,75,640,360,192);
  2217.  
  2218.  
  2219.    MyRastPtr:=AllocRaster(640,360);
  2220.    if MyRastPtr=NIL then begin
  2221.       INTROEXIT;
  2222.       exit;
  2223.    end;
  2224.    InitTmpRas(^MyTmpRas,MyRastPtr,21000);
  2225.    InitArea(^MyAI,ptr(IMemA[1]),200);
  2226.    MyScreen[1]^.RastPort.TmpRas:=^MyTmpRas; MyScreen[2]^.RastPort.TmpRas:=^MyTmpRas;
  2227.    MyScreen[1]^.RastPort.AreaInfo:=^MyAI;   MyScreen[2]^.RastPort.AreaInfo:=^MyAI;
  2228.  
  2229.    SArr:=StrArr('Software & Design',                 'OXYGENIC',
  2230.                 'Art Director',                      'CYBERTRACE',
  2231.                 'Music by',                          'LUDWIG v. BEETHOVEN',
  2232.                 'RICHARD WAGNER',                    'N.N. IKONNIKOW',
  2233.                 'JERRY GOLDSMITH',                   'ALEXANDER COURAGE',
  2234.                 'Credits go to',                     'C. MORELL',
  2235.                 'JAKOB GAARDSTED',                   'GEORGE MOORE',
  2236.                 'RIKARD CEDERLUND',                  'ANDY JONES',
  2237.                 'ADAM BENJAMIN',                     '',
  2238.                 'DolbySurround®-Sounds created with','WAVETRACER DS');
  2239.    FArr:=FontArr(4,5, 4,5, 4,5, 5,5, 5,5, 4,5,  5,5, 5,5, 5,5, 4,5);
  2240.  
  2241.    ShipX:=r_Coords( 390, 264,252,186,186,192,256,290,354,360,360,294,282, 252, 256, 290,294, 282,294,294, 258,265,273,281,288, 185,185,190,190, 356,356,361,361,0,0,0,0,0,0,0,0);
  2242.    ShipY:=r_Coords( 315, 174,275,250,188,225,234,234,225,188,250,275,174, 275, 243, 243,275, 174,275,275, 269,342,269,342,269, 187,172,172,187, 187,172,172,187,0,0,0,0,0,0,0,0);
  2243.    ShipZ:=r_Coords(-2.5,  -5, -1, -5, -5, -5, -1, -1, -5, -5, -5, -1, -5,  -1,-1.1,-1.1, -1,  -5, -8, -1,  -2, -2, -2, -2, -2,  -5, -5, -5, -5,  -5, -5, -5, -5,0,0,0,0,0,0,0,0);
  2244.  
  2245.    for i:=1 to 40 do begin
  2246.       ShipX[i]:=273-ShipX[i]; ShipY[i]:=257-ShipY[i];
  2247.    end;
  2248.    FactorSin:=sin(0.45); FactorCos:=cos(0.45);
  2249.    for j:=1 to 3 do for i:=1 to 40 do begin
  2250.       ShipY[i]:=ShipY[i]*FactorCos-ShipZ[i]*FactorSin; {X}
  2251.       ShipZ[i]:=ShipY[i]*FactorSin+ShipZ[i]*FactorCos;
  2252.    end;
  2253.    FactorSin:=sin(-0.44); FactorCos:=cos(-0.44);
  2254.    for i:=1 to 40 do begin
  2255.       ShipX[i]:=ShipX[i]*FactorCos-ShipZ[i]*FactorSin;
  2256.       ShipZ[i]:=ShipZ[i]*FactorCos+ShipX[i]*FactorSin;
  2257.    end;
  2258.    FactorSin:=sin(-0.08); FactorCos:=cos(-0.08);
  2259.    for i:=1 to 40 do begin
  2260.       ShipX[i]:=ShipX[i]*FactorCos-ShipY[i]*FactorSin;
  2261.       ShipY[i]:=ShipX[i]*FactorSin+ShipY[i]*FactorCos;
  2262.    end;
  2263.  
  2264.    Factor:=0.0074; SizeFactor:=0.009;
  2265.    LEdge[1]:=0; TEdge[1]:=75;
  2266.    LEdge[2]:=0; TEdge[2]:=75;
  2267.    l:=1; ISize:=0;
  2268.    repeat
  2269.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2270.       ShipX[0]:=ShipX[0]-Factor-Factor-0.22;
  2271.       ShipY[0]:=ShipY[0]-Factor;
  2272.       BltBitMapRastPort(^MyBitMap,LEdge[AScr],TEdge[AScr]-75,^MyScreen[AScr]^.RastPort,LEdge[AScr],TEdge[Ascr],160,80,192);
  2273.       BltBitMapRastPort(^MybitMap,0,145,^MyScreen[AScr]^.RastPort,0,220,640,55,192);
  2274.       LEdge[AScr]:=round(ShipX[0]-90); if LEdge[AScr]<0 then LEdge[AScr]:=0;
  2275.       TEdge[AScr]:=round(ShipY[0]-60); if TEdge[AScr]<75 then TEdge[AScr]:=75;
  2276.       for i:=1 to 40 do if ShipX[0]-ShipX[i]*SizeFactor<0 then begin
  2277.          FactorSin:=(ShipX[0]+abs(ShipX[0]-ShipX[i]*SizeFactor))/ShipX[0];
  2278.          ShipX[i]:=ShipX[0]/SizeFactor;
  2279.          ShipY[i]:=ShipY[i]/FactorSin;
  2280.       end;
  2281.  
  2282.       SetAPen(^MyScreen[AScr]^.RastPort,124);
  2283.       {*** Antrieb ***}
  2284.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[20]*SizeFactor),round(ShipY[0]-ShipY[20]*SizeFactor));
  2285.       for k:=21 to 24 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2286.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2287.       SetAPen(^MyScreen[AScr]^.RastPort,126);
  2288.       {*** BodenPlatte hell ***}
  2289.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[13]*SizeFactor),round(ShipY[0]-ShipY[13]*SizeFactor));
  2290.       for k:=14 to 16 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2291.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2292.       {*** Seitenwand ***}
  2293.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[17]*SizeFactor),round(ShipY[0]-ShipY[17]*SizeFactor));
  2294.       for k:=18 to 19 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2295.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2296.       SetAPen(^MyScreen[AScr]^.RastPort,127);
  2297.       {*** BodenPlatte ***}
  2298.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[1]*SizeFactor),round(ShipY[0]-ShipY[1]*SizeFactor));
  2299.       for k:=2 to 12 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2300.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2301.       SetAPen(^MyScreen[AScr]^.RastPort,125);
  2302.       {*** Waffen ***}
  2303.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[25]*SizeFactor),round(ShipY[0]-ShipY[25]*SizeFactor));
  2304.       for k:=26 to 28 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2305.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2306.       AreaMove(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[29]*SizeFactor),round(ShipY[0]-ShipY[29]*SizeFactor));
  2307.       for k:=30 to 32 do AreaDraw(^MyScreen[AScr]^.RastPort,round(ShipX[0]-ShipX[k]*SizeFactor),round(ShipY[0]-ShipY[k]*SizeFactor));
  2308.       AreaEnd(^MyScreen[AScr]^.RastPort);
  2309.       SetAPen(^MyScreen[AScr]^.RastPort,0);
  2310.       RectFill(^MyScreen[AScr]^.RastPort,0,75,0,200);
  2311.       if ISize>1 then begin
  2312.          WRITE(320,220,125,16,MyScreen[AScr]^,FArr[l],SArr[l]);
  2313.          WRITE(320,245,125,16,MyScreen[AScr]^,FArr[l+1],SArr[l+1]);
  2314.       end;
  2315.       ISize:=ISize+1;
  2316.       if ISize>44 then begin
  2317.          l:=l+2; ISize:=0;
  2318.       end;
  2319.       Factor:=Factor*1.018; SizeFactor:=SizeFactor*1.0137;
  2320.    until (Factor>3.2) or (SizeFactor>3.2);
  2321.    if LData^ and 64=0 then begin
  2322.       INTROEXIT; exit;
  2323.    end;
  2324.    if l<20 then repeat
  2325.       ScreenToFront(MyScreen[AScr]); AScr:=3-AScr;
  2326.       BltBitMapRastPort(^MybitMap,0,0,^MyScreen[AScr]^.RastPort,0,75,640,360,192);
  2327.       if ISize>0 then begin
  2328.          WRITE(320,220,125,16,MyScreen[AScr]^,FArr[l],SArr[l]);
  2329.          WRITE(320,245,125,16,MyScreen[AScr]^,FArr[l+1],SArr[l+1]);
  2330.       end;
  2331.       ISize:=ISize+1;
  2332.       if ISize>16 then begin
  2333.          l:=l+2; ISize:=0;
  2334.       end;
  2335.       Factor:=Factor*1.018; SizeFactor:=SizeFactor*1.0137;
  2336.    until l>20;
  2337.    INTROEXIT;
  2338. end;
  2339.  
  2340.  
  2341.  
  2342. procedure SETWORLDCOLORS;
  2343.  
  2344. begin
  2345.    case GETCIVVAR(Save.WorldFlag) of
  2346.       1: SetRGB32(^MyScreen[1]^.ViewPort,1,$66000000,$66000000,$F7000000);
  2347.       2: SetRGB32(^MyScreen[1]^.ViewPort,1,$FF000000,0,0);
  2348.       3: SetRGB32(^MyScreen[1]^.ViewPort,1,0,$FF000000,$12000000);
  2349.       4: SetRGB32(^MyScreen[1]^.ViewPort,1,$FF000000,$FF000000,0);
  2350.       5: SetRGB32(^MyScreen[1]^.ViewPort,1,$BA000000,$8B000000,$48000000);
  2351.       6: SetRGB32(^MyScreen[1]^.ViewPort,1,$FF000000,0,$B0000000);
  2352.       7: SetRGB32(^MyScreen[1]^.ViewPort,1,$77000000,$77000000,$77000000);
  2353.       otherwise SetRGB32(^MyScreen[1]^.ViewPort,1,$0,$FF000000,$FF000000);
  2354.    end;
  2355. end;
  2356.  
  2357.  
  2358.  
  2359. procedure INITSOUNDS;
  2360.  
  2361. var l,ISize     :long;
  2362.  
  2363. procedure LOADSOUND(FName :str; SID :byte);
  2364.  
  2365. var l           :long;
  2366.  
  2367. begin
  2368.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  2369.    if FHandle=0 then exit;
  2370.    l:=DosSeek(FHandle,0,OFFSET_END);
  2371.    l:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  2372.    SoundSize[SID]:=l div 2;
  2373.    SoundMemA[SID]:=AllocMem(SoundSize[SID]*2,MEMF_CHIP+MEMF_CLEAR);
  2374.    if SoundMemA[SID]=0 then begin
  2375.       DosClose(FHandle);   exit;
  2376.    end;
  2377.    l:=DosRead(FHandle,ptr(SoundMemA[SID]),SoundSize[SID]*2);
  2378.    DosClose(FHandle);
  2379. end;
  2380.  
  2381.  
  2382. begin
  2383.    s:=PathStr[7]+'Blip.RAW';
  2384.    LOADSOUND(s,1);
  2385.    s:=PathStr[7]+'DestroyDS.RAW';
  2386.    LOADSOUND(s,2);
  2387.    s:=PathStr[7]+'StargateDS.RAW';
  2388.    LOADSOUND(s,3);
  2389. end;
  2390.  
  2391.  
  2392.  
  2393. function INITDESK(Mode :byte):boolean;
  2394.  
  2395. var l,ISize     :long;
  2396.  
  2397.  
  2398. procedure LOADMOD(FName :str; MID :byte);
  2399.  
  2400. begin
  2401.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  2402.    if FHandle<>0 then begin
  2403.       ModMemL[MID]:=DosSeek(FHandle,0,OFFSET_END);
  2404.       ModMemL[MID]:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  2405.       ModMemA[MID]:=AllocMem(ModMemL[MID],MEMF_FAST+MEMF_CLEAR);
  2406.       if ModMemA[MID]<>0 then l:=DosRead(FHandle,ptr(ModMemA[MID]),ModMemL[MID]);
  2407.       DosClose(FHandle);
  2408.    end;
  2409. end;
  2410.  
  2411.  
  2412. begin
  2413.    INITDESK:=false;
  2414.    s:=PathStr[1]+'Desk.pal';
  2415.    l:=SETCOLOR(MyScreen[1]^,s);
  2416.    s:=PathStr[1]+'Desk.img';
  2417.    if not DISPLAYIMAGE(s,512,0,128,512,7,MyScreen[1]^,0) then exit;
  2418.    SETWORLDCOLORS;
  2419.  
  2420.    WRITE(554,156,45,0,MyScreen[1]^,4,'Jahr');
  2421.    WRITE(535,207,45,0,MyScreen[1]^,4,'Guthaben');
  2422.    WRITE(533,258,45,0,MyScreen[1]^,4,'Population');
  2423.    s:=PathStr[6]+'ST/DeskImages.img';
  2424.    if not RAWLOADIMAGE(s,0,32,640,32,4,ImgBitMap4) then exit;
  2425.  
  2426.    if Mode=1 then begin
  2427.       s:=PathStr[1]+'DeskImages.img';
  2428.       if not RAWLOADIMAGE(s,0,0,416,32,7,ImgBitMap7) then exit;
  2429.       s:=PathStr[1]+'ProjectIcons.img';
  2430.       if not RAWLOADIMAGE(s,0,0,640,192,8,ImgBitMap8) then exit;
  2431.  
  2432.       IMemL[1]:=4480;
  2433.       IMemA[1]:=AllocMem(IMemL[1],MEMF_CHIP+MEMF_CLEAR);
  2434.       if IMemA[1]=0 then exit;
  2435.       s:=PathStr[1]+'DeskGads.img';
  2436.       FHandle:=OPENSMOOTH(s,MODE_OLDFILE);       {Planets/Deskgads.img}
  2437.       if FHandle=0 then begin
  2438.          FreeMem(IMemA[1],IMemL[1]);
  2439.          IMemA[1]:=0;
  2440.          exit;
  2441.       end;
  2442.       l:=DosRead(FHandle,ptr(IMemA[1]),4480);
  2443.       DosClose(FHandle);
  2444.       GadImg1:=Image(0,0,116,20,7,ptr(IMemA[1]),127,0,NIL);
  2445.       GadImg2:=Image(0,0,116,20,7,ptr(IMemA[1]+2240),127,0,NIL);
  2446.  
  2447.       s:=PathStr[5]+'MOD.Invention';
  2448.       LOADMOD(s,1);
  2449.       s:=PathStr[5]+'MOD.War';
  2450.       LOADMOD(s,2);
  2451.       s:=PathStr[5]+'MOD.Tech';
  2452.       LOADMOD(s,3);
  2453.       s:=PathStr[5]+'MOD.Bad';
  2454.       LOADMOD(s,4);
  2455.  
  2456.       s:=PathStr[8]+'Worm.img';
  2457.       if not RAWLOADIMAGE(s,0,32,512,32,7,ImgBitMap7) then exit;
  2458.       s:=PathStr[8]+'XPlode.img';
  2459.       if not RAWLOADIMAGE(s,0,0,512,32,4,ImgBitMap4) then exit;
  2460.    end;
  2461.  
  2462.    INITDESK:=true;
  2463. end;
  2464.  
  2465.  
  2466.  
  2467. procedure CREATENEWSYSTEM(ActSys,CivVar :byte);
  2468.  
  2469. var i,j,l               :integer;
  2470. var sin_rot,cos_rot,d   :real;
  2471. var btx                 :byte;
  2472. var MyPlanetHeader      :^r_PlanetHeader;
  2473. var DefaultShip         :r_ShipHeader;
  2474.  
  2475. begin
  2476.    Save.ImperatorState[CivVar]:=Save.ImperatorState[CivVar]+50;
  2477.    randomize;
  2478.    with SystemHeader[ActSys] do begin
  2479.       Planets:=random(MAXPLANETS+5);
  2480.       if Planets<4 then Planets:=4;
  2481.       if Planets>MAXPLANETS then Planets:=MAXPLANETS;
  2482.       PlanetMemA:=AllocMem(Planets*sizeof(r_PlanetHeader),MEMF_CLEAR);
  2483.       if PlanetMemA=0 then begin
  2484.          Planets:=0;
  2485.          exit;
  2486.       end;
  2487.       btx:=0;
  2488.       for i:=0 to pred(Planets) do begin
  2489.          MyPlanetHeader:=ptr(PlanetMemA+i*sizeof(r_PlanetHeader));
  2490.          with MyPlanetHeader^ do begin
  2491.             Class:=random(9);
  2492.             if Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,CLASS_ICE,
  2493.                          CLASS_STONES,CLASS_WATER] then btx:=1;
  2494.             Size:=random(206)+1;
  2495.             case Class of
  2496.                CLASS_DESERT    : Water:=Size*13;
  2497.                CLASS_HALFEARTH : Water:=Size*38;
  2498.                CLASS_EARTH     : Water:=Size*73;
  2499.                CLASS_ICE       : Water:=Size*85;
  2500.                CLASS_STONES    : Water:=Size*42;
  2501.                CLASS_WATER     : Water:=Size*92;
  2502.                otherwise Water:=0;
  2503.             end;
  2504.             PFlags:=0;
  2505.             PName:=Save.SystemName[ActSys]+' '+Romanum[i+1];
  2506.             PosX:=i*3+4;
  2507.             PosY:=PosX;
  2508.             if (Class in [CLASS_EARTH,CLASS_WATER]) and (random(10)=0) then Biosphäre:=150+random(50) else Biosphäre:=0;
  2509.             Infrastruktur:=0;
  2510.             Industrie:=0;
  2511.             Population:=0;
  2512.             XProjectCosts:=0;       XProjectPayed:=1;
  2513.             ProjectID:=0;           ProjectPtr:=NIL;
  2514.          end;
  2515.       end;
  2516.       DefaultShip:=r_ShipHeader(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NIL,NIL,NIL);
  2517.       if btx=0 then begin
  2518.          i:=random(2)+2;
  2519.          MyPlanetHeader:=ptr(PlanetMemA+i*sizeof(r_PlanetHeader));
  2520.          l:=random(50)+5;
  2521.          MyPlanetHeader^:=r_PlanetHeader(CLASS_EARTH,succ(random(197)),0,0,Save.SystemName[ActSys]+' '+Romanum[i+1],
  2522.                                          i*3+4,0,l,l*73,200,random(50)+50,random(50)+50,0,0,0,DefaultShip,NIL);
  2523.       end;
  2524.       l:=Planets*20;
  2525.       for i:=1 to l do for j:=1 to SystemHeader[ActSys].Planets do begin
  2526.          MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  2527.          with MyPlanetHeader^ do begin
  2528.             d:=1/((j*3)+1);
  2529.             sin_rot:=sin(d);  cos_rot:=cos(d);
  2530.             PosX:=PosX * cos_rot - PosY*sin_rot;
  2531.             PosY:=PosX * sin_rot + PosY*cos_rot*(1+d*d);
  2532.             if round(PosX)=round(PosY) then PosX:=round(PosY);
  2533.          end;
  2534.       end;
  2535.    end;
  2536. end;
  2537.  
  2538.  
  2539.  
  2540. procedure LINKSHIP(SPtr,TPtr  :ptr, Mode :byte);
  2541.  
  2542. var SourcePtr,TargetPtr         :^r_ShipHeader;
  2543.  
  2544. begin
  2545.    SourcePtr:=SPtr; TargetPtr:=TPtr;
  2546.    if Mode=1 then begin
  2547.       SourcePtr^.BeforeShip^.NextShip:=SourcePtr^.NextShip;
  2548.       if SourcePtr^.NextShip<>NIL then
  2549.        SourcePtr^.NextShip^.BeforeShip:=SourcePtr^.BeforeShip;
  2550.    end;
  2551.    SourcePtr^.BeforeShip:=TargetPtr;
  2552.    SourcePtr^.NextShip:=TargetPtr^.NextShip;
  2553.    TargetPtr^.NextShip:=SourcePtr;
  2554.    if SourcePtr^.NextShip<>NIL then
  2555.     SourcePtr^.NextShip^.BeforeShip:=SourcePtr;
  2556. end;
  2557.  
  2558.  
  2559.  
  2560. procedure FINDENEMYSYSTEM(ActSys,CivVar :byte; ShipPtr :ptr;);
  2561.  
  2562. var l                           :long;
  2563. var i,k                         :integer;
  2564. var SysEntfernung,SysID,btx     :byte;
  2565. var b                           :boolean;
  2566. var MyShipPtr                   :^r_ShipHeader;
  2567.  
  2568. begin
  2569.    MyShipPtr:=ShipPtr;
  2570.    SysEntfernung:=255; SysID:=0;
  2571.    for i:=1 to Save.SYSTEMS do if i<>ActSys then begin
  2572.       l:=abs(SystemX[ActSys]-SystemX[i]);
  2573.       if abs(SystemY[ActSys]-SystemY[i])>l then l:=abs(SystemY[ActSys]-SystemY[i]);
  2574.       if ((SystemFlags[ActPlayer,i] and FLAG_CIV_MASK<>0)
  2575.       and (SystemFlags[1,i] and FLAG_CIV_MASK<>0))
  2576.       or (MyShipPtr^.Flags=SHIPFLAG_WATER) then begin
  2577.          if (l<SysEntfernung) and (MyShipPtr^.Flags=SHIPFLAG_WATER)
  2578.          and (random(3)=0) then begin
  2579.             SysEntfernung:=l; SysID:=i;
  2580.             if (SystemHeader[ActSys].FirstShip.SType=TARGET_STARGATE)
  2581.              and (SystemHeader[SysID].FirstShip.SType=TARGET_STARGATE)
  2582.              then SysEntfernung:=255;
  2583.          end else if (l<SysEntfernung) and (SystemFlags[1,i] and FLAG_CIV_MASK<>0)
  2584.          and (Save.WarState[CivVar,GETCIVVAR(SystemFlags[1,i])] in [LEVEL_WAR,LEVEL_COLDWAR])
  2585.          then begin
  2586.             SysEntfernung:=l; SysID:=i;
  2587.          end;
  2588.       end;
  2589.    end;
  2590.    if SysID=0 then SysID:=random(Save.SYSTEMS)+1;
  2591.    if SystemHeader[SysID].Planets=0 then CREATENEWSYSTEM(SysID,CivVar);
  2592.    if (SystemHeader[ActSys].FirstShip.SType=TARGET_STARGATE)
  2593.     and (SystemHeader[SysID].FirstShip.SType=TARGET_STARGATE) then begin
  2594.       MyShipPtr^.Target:=TARGET_ENEMY_SHIP;
  2595.       MyShipPtr^.TargetShip:=^SystemHeader[ActSys].FirstShip;
  2596.       MyShipPtr^.Source:=SysID;
  2597.       exit;
  2598.    end;
  2599.    for i:=1 to MAXHOLES do if MyWormHole[i].CivKnowledge[CivVar]=FLAG_KNOWN then
  2600.    with MyWormhole[i] do for j:=1 to 2 do if (System[j]=ActSys) and
  2601.    (SystemFlags[1,System[3-j]] and FLAG_CIV_MASK<>0) then if
  2602.    (Save.WarState[CivVar,GETCIVVAR(SystemFlags[1,System[3-j]])] in [LEVEL_WAR,LEVEL_COLDWAR])
  2603.    then SysID:=System[3-j]; {*** Feindliche Systeme mit Wurmloch bevorzugt angreifen ****}
  2604.  
  2605.    for i:=1 to MAXHOLES do if MyWormHole[i].CivKnowledge[CivVar]=FLAG_KNOWN then
  2606.    with MyWormHole[i] do for j:=1 to 2 do if (System[j]=ActSys) and (System[3-j]=SysID) then begin
  2607.       MyShipPtr^.Target:=-i;
  2608.       MyShipPtr^.Source:=-j;
  2609.       exit;
  2610.    end;
  2611.    MyShipPtr^.Source:=ActSys;
  2612.    MyShipPtr^.Target:=SysID;
  2613.    l:=-(SysEntfernung div ShipData[MyShipPtr^.SType].MaxMove)-1;
  2614.    if l<-127 then l:=-127;
  2615.    MyShipPtr^.Moving:=l;
  2616.    LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,1);
  2617. end;
  2618.  
  2619.  
  2620.  
  2621. function FINDMAQUESSHIP(ActSys :byte; MyShipPtr :ShipHeader):boolean;
  2622.  
  2623. var CivVar,CivVar2              :byte;
  2624. var OtherShipPtr                :^r_ShipHeader;
  2625. var DistOld,DistNew             :long;
  2626.  
  2627. begin
  2628.    FINDMAQUESSHIP:=false;
  2629.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  2630.    if CivVar in [0,9] then exit;
  2631.    DistOld:=10000;
  2632.    if SystemHeader[ActSys].FirstShip.NextShip<>NIL then begin
  2633.       OtherShipPtr:=SystemHeader[ActSys].FirstShip.NextShip;
  2634.       while OtherShipPtr<>NIL do begin
  2635.          CivVar2:=GETCIVVAR(OtherShipPtr^.Owner);
  2636.          if (OtherShipPtr^.Moving>=0) and (CivVar2=9) then begin
  2637.             DistNew:=abs(OtherShipPtr^.PosX-MyShipPtr^.PosX);
  2638.             if abs(OtherShipPtr^.PosY-MyShipPtr^.PosY)>DistNew then DistNew:=abs(OtherShipPtr^.PosY-MyShipPtr^.PosY);
  2639.             if DistNew<DistOld then begin
  2640.                DistOld:=DistNew;
  2641.                FINDMAQUESSHIP:=true;
  2642.                MyShipPtr^.Target:=TARGET_ENEMY_SHIP;
  2643.                MyShipPtr^.TargetShip:=OtherShipPtr;
  2644.             end;
  2645.          end;
  2646.          OtherShipPtr:=OtherShipPtr^.NextShip;
  2647.       end;
  2648.    end;
  2649. end;
  2650.  
  2651.  
  2652.  
  2653.  
  2654. procedure FINDENEMYOBJECT(ActSys :byte; ShipPtr :ptr);
  2655.  
  2656. var btx,CivVar,CivVar2          :byte;
  2657. var MyPlanetHeader              :^r_PlanetHeader;
  2658. var MyShipPtr,OtherShipPtr      :^r_ShipHeader;
  2659. var DistOld,DistNew             :long;
  2660. var k                           :integer;
  2661. var ActPProjects                :^ByteArr42;
  2662.  
  2663. begin
  2664.    MyShipPtr:=ShipPtr;
  2665.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  2666.    if CivVar=0 then exit;
  2667.    btx:=0;
  2668.    DistOld:=10000;
  2669.    for k:=0 to pred(SystemHeader[ActSys].Planets) do begin
  2670.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+k*sizeof(r_PlanetHeader));
  2671.       CivVar2:=GETCIVVAR(MyPlanetHeader^.PFlags);
  2672.       ActPProjects:=MyPlanetHeader^.ProjectPtr;
  2673.       if (CivVar2<>0) and (CivVar2<>CivVar) then begin
  2674.          if (Save.WarState[CivVar,CivVar2] in [LEVEL_WAR,LEVEL_COLDWAR]) then begin
  2675.             if (MyShipPtr^.Ladung and MASK_LTRUPPS>0) or (MyPlanetHeader^.FirstShip.NextShip<>NIL)
  2676.             or (ActPProjects^[34]>0) or (ActPProjects^[40]>0) or (CivVar=9) then begin
  2677.                DistNew:=round(abs(MyPlanetHeader^.PosX-MyShipPtr^.PosX));
  2678.                if round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY))>DistNew then DistNew:=round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY));
  2679.                if DistNew<=DistOld then begin
  2680.                   DistOld:=DistNew;
  2681.                   if btx=0 then btx:=k+1;
  2682.                   MyShipPtr^.Target:=k+1;
  2683.                   MyShipPtr^.Source:=ActSys;
  2684.                end;
  2685.             end;
  2686.          end;
  2687.       end;
  2688.    end;
  2689.    if (btx>0) and (MyShipPtr^.Owner=FLAG_MAQUES) then exit;
  2690.    if SystemHeader[ActSys].FirstShip.NextShip<>NIL then begin
  2691.       OtherShipPtr:=SystemHeader[ActSys].FirstShip.NextShip;
  2692.       if MyShipPtr^.Owner<>FLAG_MAQUES then while OtherShipPtr<>NIL do begin
  2693.          CivVar2:=GETCIVVAR(OtherShipPtr^.Owner);
  2694.          if (OtherShipPtr^.Moving>=0) and not (CivVar2 in [CivVar,0]) then begin
  2695.             if Save.WarState[CivVar,CivVar2] in [LEVEL_WAR,LEVEL_COLDWAR] then begin
  2696.                DistNew:=abs(OtherShipPtr^.PosX-MyShipPtr^.PosX);
  2697.                if abs(OtherShipPtr^.PosY-MyShipPtr^.PosY)>DistNew then DistNew:=abs(OtherShipPtr^.PosY-MyShipPtr^.PosY);
  2698.                if DistNew<DistOld then begin
  2699.                   DistOld:=DistNew;
  2700.                   btx:=1;
  2701.                   MyShipPtr^.Target:=TARGET_ENEMY_SHIP;
  2702.                   MyShipPtr^.TargetShip:=OtherShipPtr;
  2703.                end;
  2704.             end;
  2705.          end;
  2706.          OtherShipPtr:=OtherShipPtr^.NextShip;
  2707.       end;
  2708.       if btx=0 then begin
  2709.          MyShipPtr^.Target:=1;
  2710.          FINDENEMYSYSTEM(ActSys,CivVar,MyShipPtr);
  2711.       end;
  2712.    end;
  2713. end;
  2714.  
  2715.  
  2716.  
  2717. procedure REFRESHDISPLAY;
  2718.  
  2719. var Mode        :byte;
  2720.  
  2721. begin
  2722.    Mode:=MODE_REFRESH;
  2723.    if ((OldX<>OffsetX) or (OldY<>OffsetY)) and (Display<>0) then Mode:=MODE_REDRAW;
  2724.    if Display=0 then DRAWSTARS(Mode,ActPlayer) else DRAWSYSTEM(Mode,Display,NIL);
  2725. end;
  2726.  
  2727.  
  2728.  
  2729. procedure QUOTEPICARD;
  2730.  
  2731. begin
  2732.    MAKEBORDER(MyScreen[1]^,20,70,490,290,12,6,0);
  2733.    WRITE(256, 90,12,16,MyScreen[1]^,4,'Ich frage mich, ob es Kaiser Honorius klar');
  2734.    WRITE(256,112,12,16,MyScreen[1]^,4,'war, als er sah, das die Westgoten den siebten');
  2735.    WRITE(256,134,12,16,MyScreen[1]^,4,'Hügel Roms überwanden, das das Römische Reich');
  2736.    WRITE(256,156,12,16,MyScreen[1]^,4,'fallen würde ... Das hier ist nur eine weitere');
  2737.    WRITE(256,178,12,16,MyScreen[1]^,4,'Episode der Geschichte. Wird hier unsere');
  2738.    WRITE(256,200,12,16,MyScreen[1]^,4,'Zivilisation enden?');
  2739.    WRITE(480,228,12,32,MyScreen[1]^,4,'Jean Luc Picard');
  2740.    WRITE(480,250,12,32,MyScreen[1]^,4,'Mission "Wolf 359"');
  2741.    WAITLOOP(false);
  2742.    RECT(MyScreen[1]^,0,20,70,490,290);
  2743.    REFRESHDISPLAY;
  2744. end;
  2745.  
  2746.  
  2747.  
  2748. procedure BORGMESSAGE(CivVar :byte);
  2749.  
  2750. begin
  2751.    MAKEBORDER(MyScreen[1]^,20,70,490,225,12,6,0);
  2752.    WRITE(256, 90,1,16,MyScreen[1]^,4,'Unsere Analyse hat ergeben, das die Zivilisation');
  2753.                                   s:='der '+GETCIVNAME(CivVar)+' nicht in der Lage ist, sich';
  2754.    WRITE(256,112,1,16,MyScreen[1]^,4,s);
  2755.    WRITE(256,134,1,16,MyScreen[1]^,4,'erfolgreich gegen uns zu verteidigen. ');
  2756.    WRITE(256,156,1,16,MyScreen[1]^,4,'Ihre Zivilisation wird assimiliert.');
  2757.    WRITE(256,190,1,16,MyScreen[1]^,4,'WIDERSTAND IST ZWECKLOS!');
  2758.    WAITLOOP(false);
  2759.    RECT(MyScreen[1]^,0,20,70,490,225);
  2760.    REFRESHDISPLAY;
  2761. end;
  2762.  
  2763.  
  2764.  
  2765. procedure GOTOWAR(CivFlag1,CivFlag2 :byte);
  2766.  
  2767. var CivVar1,CivVar2   :byte;
  2768.  
  2769. begin
  2770.    CivVar1:=GETCIVVAR(CivFlag1);         CivVar2:=GETCIVVAR(CivFlag2);
  2771.    CivFlag1:=CivFlag1 and FLAG_CIV_MASK; CivFlag2:=CivFlag2 and FLAG_CIV_MASK;
  2772.    Save.ImperatorState[CivVar1]:=Save.ImperatorState[CivVar1]-150;
  2773.    if (CivVar1=0) or (CivVar2=0) or (Save.WarState[CivVar1,CivVar2]=LEVEL_WAR)
  2774.    or (Save.WarState[CivVar2,CivVar1]=LEVEL_WAR) then exit;
  2775.    Save.WarState[CivVar1,CivVar2]:=LEVEL_WAR;
  2776.    Save.WarState[CivVar2,CivVar1]:=LEVEL_WAR;
  2777.    if (CivVar1=8) and (Save.WorldFlag=WFLAG_JAHADR) then Save.JSteuer[CivVar2]:=0;
  2778.    if (CivVar2=8) and (Save.WorldFlag=WFLAG_JAHADR) then Save.JSteuer[CivVar1]:=0;
  2779.    if (Save.WarState[ActPlayer,CivVar1]=LEVEL_UNKNOWN) and (Save.WarState[ActPlayer,CivVar2]=LEVEL_UNKNOWN) then exit;
  2780.    MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  2781.    s:=GETCIVNAME(CivVar1);
  2782.    WRITE(256,131,CivFlag1,1+16,MyScreen[1]^,4,s);
  2783.    WRITE(256,151,12,1+16,MyScreen[1]^,4,'beginnen Krieg gegen');
  2784.    s:=GETCIVNAME(CivVar2);
  2785.    WRITE(256,171,CivFlag2,1+16,MyScreen[1]^,4,s);
  2786.    if Save.PlayMySelf then delay(PAUSE);
  2787.    WAITLOOP(Save.PlayMySelf);
  2788.    RECT(MyScreen[1]^,0,85,120,425,200);
  2789.    if (CivVar1=8) and (Save.WorldFlag=WFLAG_CEBORC) and (random(10)=0)
  2790.    and (Save.CivPlayer[CivVar2]<>0) then BORGMESSAGE(CivVar2);
  2791.    if (Save.CivPlayer[CivVar2]<>0) and not Save.PlayMySelf
  2792.    and (Save.WarPower[CivVar1]>Save.WarPower[CivVar2]) and (random(40)=0)
  2793.     then QUOTEPICARD
  2794.    else if (Save.CivPlayer[CivVar2]<>0) and not Save.PlayMySelf
  2795.    and (CivVar1=8) and (Save.WorldFlag in [WFLAG_CEBORC,WFLAG_JAHADR,WFLAG_DCON])
  2796.    and (random(10)=0) then QUOTEPICARD;
  2797. end;
  2798.  
  2799.  
  2800.  
  2801. function GOTONEXTSYSTEM(ActSys :byte; ShipPtr :ptr;):byte;
  2802.  
  2803. var l                                   :long;
  2804. var i,k                                 :integer;
  2805. var SysEntfernung,SysID,btx,CivVar,j    :byte;
  2806. var b                                   :boolean;
  2807. var MyShipPtr                           :^r_ShipHeader;
  2808.  
  2809. begin
  2810.    randomize;
  2811.    GOTONEXTSYSTEM:=ActSys;
  2812.    MyShipPtr:=ShipPtr;
  2813.    if not (MyShipPtr^.SType in [8..24]) then begin
  2814.       MyShipPtr^.SType:=8;
  2815.       MyShipPtr^.Owner:=0;
  2816.    end;
  2817.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  2818.    SysEntfernung:=255; SysID:=0;
  2819.    for i:=1 to Save.SYSTEMS do if i<>ActSys then begin
  2820.       l:=abs(SystemX[ActSys]-SystemX[i]);
  2821.       if abs(SystemY[ActSys]-SystemY[i])>l then l:=abs(SystemY[ActSys]-SystemY[i]);
  2822.       if (l<SysEntfernung) and (random(2)=0) then begin
  2823.          if ((Save.GlobalFlags[CivVar]=GFLAG_EXPLORE) and (SystemHeader[i].State and STATE_TACTICAL=0))
  2824.          or ((MyShipPtr^.Flags=SHIPFLAG_WATER) and
  2825.          (((MyShipPtr^.Fracht>0) and (SystemFlags[1,i] and FLAG_CIV_MASK<>0))
  2826.          or (MyShipPtr^.Fracht=0))) or (CivVar=9) then begin
  2827.             SysEntfernung:=l; SysID:=i;
  2828.             if (SystemHeader[ActSys].FirstShip.SType=TARGET_STARGATE)
  2829.              and (SystemHeader[SysID].FirstShip.SType=TARGET_STARGATE)
  2830.              then SysEntfernung:=255;
  2831.          end;
  2832.       end;
  2833.    end;
  2834.    if SysID=0 then begin
  2835.       Save.GlobalFlags[CivVar]:=GFLAG_ATTACK;
  2836.       MyShipPtr^.Moving:=0;
  2837.       exit;
  2838.    end;
  2839.    if SystemHeader[SysID].Planets=0 then CREATENEWSYSTEM(SysID,CivVar);
  2840.    if (SystemHeader[ActSys].FirstShip.SType=TARGET_STARGATE)
  2841.    and (SystemHeader[SysID].FirstShip.SType=TARGET_STARGATE) then begin
  2842.       MyShipPtr^.Target:=TARGET_ENEMY_SHIP;
  2843.       MyShipPtr^.TargetShip:=^SystemHeader[ActSys].FirstShip;
  2844.       MyShipPtr^.Source:=SysID;
  2845.       exit;
  2846.    end;
  2847.    for i:=1 to MAXHOLES do if MyWormHole[i].CivKnowledge[CivVar]=FLAG_KNOWN then
  2848.    with MyWormHole[i] do for j:=1 to 2 do if (System[j]=ActSys) and (System[3-j]=SysID) then begin
  2849.       MyShipPtr^.Target:=-i;
  2850.       MyShipPtr^.Source:=-j;
  2851.       exit;
  2852.    end;
  2853.    MyShipPtr^.Source:=ActSys;
  2854.    MyShipPtr^.Target:=SysID;
  2855.    l:=-(SysEntfernung div ShipData[MyShipPtr^.SType].MaxMove)-1;
  2856.    if l<-127 then l:=-127;
  2857.    MyShipPtr^.Moving:=l;
  2858.    LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,1);
  2859.    GOTONEXTSYSTEM:=SysID;
  2860. end;
  2861.  
  2862.  
  2863.  
  2864. function EXISTSPLANET(CivVar,ActSys,Mode :byte):boolean;
  2865.  
  2866. var MyPlanetHeader      :^r_PlanetHeader;
  2867. var i,CivFlag           :byte;
  2868.  
  2869. begin
  2870.    EXISTSPLANET:=false;
  2871.    CivFlag:=GETCIVFLAG(CivVar);
  2872.    for i:=0 to pred(SystemHeader[ActSys].Planets) do begin
  2873.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+i*sizeof(r_PlanetHeader));
  2874.       with MyPlanetHeader^ do if (((Mode=1) and (Water div Size>56))
  2875.        or ((Mode=2) and (Water div Size<55)))
  2876.        and not (Class in [CLASS_STONES,CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM])
  2877.        then begin
  2878.          if ((PFlags and FLAG_CIV_MASK) in [CivFlag,0]) then begin
  2879.             EXISTSPLANET:=true;
  2880.             exit;
  2881.          end else if Save.WarState[CivVar,GETCIVVAR(PFlags)] in [LEVEL_WAR,LEVEL_COLDWAR] then begin
  2882.             EXISTSPLANET:=true;
  2883.             exit;
  2884.          end;
  2885.       end;
  2886.    end;
  2887. end;
  2888.  
  2889.  
  2890.  
  2891. function FINDNEXTPLANET(ActSys :byte; ShipPtr :ptr):byte;
  2892.  
  2893. var btx,CivVar,CivFlag                  :byte;
  2894. var MyPlanetHeader                      :^r_PlanetHeader;
  2895. var MyShipPtr,OtherShipPtr              :^r_ShipHeader;
  2896. var k                                   :integer;
  2897. var DistOld,DistNew,WPerc,WPercLow      :long;
  2898.  
  2899. begin
  2900.    FINDNEXTPLANET:=ActSys;
  2901.    if FINDMAQUESSHIP(ActSys,ShipPtr) then exit;
  2902.    MyShipPtr:=ShipPtr;
  2903.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  2904.    CivFlag:=MyShipPtr^.Owner and FLAG_CIV_MASK;
  2905.    btx:=0;
  2906.    DistOld:=10000;
  2907.    for k:=0 to pred(SystemHeader[ActSys].Planets) do begin
  2908.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+k*sizeof(r_PlanetHeader));
  2909.       OtherShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  2910.       while (OtherShipPtr<>NIL) and (OtherShipPtr^.Owner=0) do OtherShipPtr:=OtherShipPtr^.NextShip;
  2911.       if MyPlanetHeader^.Size=0 then MyPlanetHeader^.Size:=1;
  2912.       WPerc:=MyPlanetHeader^.Water div MyPlanetHeader^.Size;
  2913.       WPercLow:=(MyPlanetHeader^.Water-5) div MyPlanetHeader^.Size;
  2914.       if ((MyShipPtr^.Ladung and MASK_SIEDLER>0) and
  2915.           (MyPlanetHeader^.Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,
  2916.                                      CLASS_ICE,CLASS_STONES,CLASS_WATER]) and
  2917.           (MyPlanetHeader^.PFlags=0) and (OtherShipPtr=NIL))
  2918.  
  2919.       or ((MyShipPtr^.Ladung=0) and (MyShipPtr^.Fracht=0) and
  2920.         not (MyPlanetHeader^.Class in [CLASS_STONES,CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM]) and
  2921.         ((MyPlanetHeader^.PFlags and FLAG_CIV_MASK in [CivFlag,0])
  2922.         or (Save.WarState[CivVar,GETCIVVAR(MyPlanetHeader^.PFlags)]=LEVEL_WAR)) and
  2923.         (WPercLow>56))
  2924.  
  2925.       or ((MyShipPtr^.Fracht>0) and (WPerc<55) and
  2926.       not (MyPlanetHeader^.Class in [CLASS_STONES,CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM]) and
  2927.       (MyPlanetHeader^.PFlags and FLAG_CIV_MASK=CivFlag)) then begin
  2928.          DistNew:=round(abs(MyPlanetHeader^.PosX-MyShipPtr^.PosX));
  2929.          if round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY))>DistNew then DistNew:=round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY));
  2930.          if DistNew<DistOld then begin
  2931.             DistOld:=DistNew;
  2932.             if btx=0 then btx:=k+1;
  2933.             MyShipPtr^.Target:=k+1;
  2934.             MyShipPtr^.Source:=0;
  2935.             MyShipPtr^.TargetShip:=NIL;
  2936.          end;
  2937.       end;
  2938.    end;
  2939.    if btx<=0 then begin
  2940.       SystemHeader[ActSys].State:=SystemHeader[ActSys].State or STATE_ALL_OCC;
  2941.       FINDNEXTPLANET:=GOTONEXTSYSTEM(ActSys,MyShipPtr);
  2942.    end else SystemHeader[ActSys].State:=SystemHeader[ActSys].State and not STATE_ALL_OCC;
  2943. end;
  2944.  
  2945.  
  2946.  
  2947. procedure INITSCREEN(Mode :byte);
  2948.  
  2949. var i           :integer;
  2950. var l           :long;
  2951.  
  2952. begin
  2953.    if Mode=SCREEN_TECH then begin
  2954.       s:=PathStr[6]+'ST/ShipTech.img';
  2955.       if not DISPLAYIMAGE(s,0,0,640,512,3,MyScreen[2]^,1) then exit;
  2956.    end;
  2957.    if Mode=Screen2 then exit;
  2958.    IMemID:=false;
  2959.    if Mode=SCREEN_PLANET then begin
  2960.       RECT(MyScreen[2]^,0,0,0,639,511);
  2961.       s:=PathStr[1]+'PlanetDesk.img';
  2962.       if not DISPLAYIMAGE(s,0,94,384,394,8,MyScreen[2]^,2) then exit;
  2963.       WRITE(62,126,2,0,MyScreen[2]^,4,'Biosphäre');
  2964.       WRITE(62,175,2,0,MyScreen[2]^,4,'Infrastruktur');
  2965.       WRITE(62,224,2,0,MyScreen[2]^,4,'Industrialisierung');
  2966.       WRITE(165,250,2,0,MyScreen[2]^,4,'Millionen');
  2967.       WRITE(62,273,2,0,MyScreen[2]^,4,'Population');
  2968.       WRITE(185,312,2,0,MyScreen[2]^,4,'Kreativität');
  2969.       WRITE(185,359,2,0,MyScreen[2]^,4,'Produktivität');
  2970.       WRITE(120,461,2,16,MyScreen[2]^,4,'Ändern');
  2971.       WRITE(262,461,2,16,MyScreen[2]^,4,'Kaufen');
  2972.       for i:=1 to 3 do WRITE(333,i*49+54,2,0,MyScreen[2]^,4,'%');
  2973.       WRITE(333,402,2,0,MyScreen[2]^,4,'%');
  2974.    end else if Mode=SCREEN_HISCORE then begin
  2975.       s:=PathStr[5]+'ST/HiScore.img';
  2976.       if not DISPLAYIMAGE(s,0,0,640,512,7,MyScreen[2]^,3) then exit;
  2977.    end;
  2978.    Screen2:=Mode;
  2979. end;
  2980.  
  2981.  
  2982.  
  2983. procedure CREATEHIGHSCORE;
  2984.  
  2985. var FHandle             :BPTR;
  2986. var i                   :byte;
  2987. var l                   :long;
  2988.  
  2989. begin
  2990.    with HiScore do begin
  2991.       s:=PathStr[5]+'ST/HiScore.dat';
  2992.       FHandle:=DosOpen(s,MODE_NEWFILE);
  2993.       if FHandle=0 then begin
  2994.          ScreenToFront(MyScreen[1]);
  2995.          exit;
  2996.       end;
  2997.       for i:=1 to 8 do begin
  2998.          Points[i]:=2800+(9-i)*2150;
  2999.          CivVar[i]:=i;
  3000.          if i=8 then CivVar[i]:=1;
  3001.       end;
  3002.       Player[1]:='Oxygenic';     Player[2]:='Kha`thak';
  3003.       Player[3]:='Tomalak';      Player[4]:='Megalith';
  3004.       Player[5]:='Monolith';     Player[6]:='The One';
  3005.       Player[7]:='Dark Blitter'; Player[8]:='CyberTrace';
  3006.       l:=DosWrite(FHandle,^HiScore,sizeof(r_Hiscore));
  3007.       DosClose(FHandle);
  3008.    end;
  3009. end;
  3010.  
  3011.  
  3012.  
  3013. procedure HIGHSCORE;
  3014.  
  3015. var FHandle     :BPTR;
  3016. var i           :byte;
  3017. var l           :long;
  3018.  
  3019.  
  3020. function GETCOLOR(Col :byte):byte;
  3021.  
  3022. begin
  3023.    case Col of
  3024.       1: GETCOLOR:=123;
  3025.       2: GETCOLOR:=124;
  3026.       3: GETCOLOR:=125;
  3027.       4: GETCOLOR:=122;
  3028.       5: GETCOLOR:=35;
  3029.       6: GETCOLOR:=126;
  3030.       7: GETCOLOR:=8;
  3031.       otherwise GETCOLOR:=127;
  3032.    end;
  3033. end;
  3034.  
  3035.  
  3036. begin
  3037.    SWITCHDISPLAY;
  3038.    INITSCREEN(SCREEN_HISCORE);
  3039.    WRITE(320,60,127,80,MyScreen[2]^,5,'IMPERIUM TERRANUM HIGHSCORES');
  3040.    s:=PathStr[5]+'ST/HiScore.dat';
  3041.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  3042.    if FHandle=0 then begin
  3043.       CREATEHIGHSCORE;
  3044.       s:=PathStr[5]+'ST/HiScore.dat';
  3045.       FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  3046.       if FHandle=0 then begin
  3047.          ScreenToBack(MyScreen[2]);
  3048.          exit;
  3049.       end;
  3050.    end;
  3051.    l:=DosRead(FHandle,^HiScore,sizeof(r_HiScore));
  3052.    DosClose(FHandle);
  3053.    for i:=1 to 8 do with HiScore do begin
  3054.       s:=intstr(Points[i]);
  3055.       WRITE(120,100+i*30,GETCOLOR(CivVar[i]),32+64,MyScreen[2]^,5,s);
  3056.       WRITE(140,100+i*30,GETCOLOR(CivVar[i]),64,MyScreen[2]^,5,Player[i]);
  3057.    end;
  3058.    ScreenToFront(MyScreen[2]);
  3059.    repeat
  3060.       delay(RDELAY);
  3061.    until (LData^ and 64=0) or (RData^ and 1024=0);
  3062.    PLAYSOUND(1,300);
  3063.    repeat
  3064.       delay(RDELAY);
  3065.    until (not (LData^ and 64=0) and not (RData^ and 1024=0)) or Bool;
  3066.    ScreenToBack(MyScreen[2]);
  3067. end;
  3068.  
  3069.  
  3070.  
  3071. function GETPLAYERNAME(ActPlayer :byte):string;
  3072.  
  3073. var VWindow             :^Window;
  3074. var VKey                :byte;
  3075. var PName               :string[20];
  3076. var s                   :string;
  3077.  
  3078. begin
  3079.    GETPLAYERNAME:='SpielerX';
  3080.    RECT(MyScreen[2]^,0,0,0,639,511);
  3081.    NeuWindow:=NewWindow(0,0,640,512,0,0,VANILLAKEY,BORDERLESS+BACKDROP+ACTIVATE+
  3082.                         SIMPLE_REFRESH,NIL,NIL,'',MyScreen[2],NIL,640,512,640,512,CUSTOMSCREEN);
  3083.    VWindow:=OpenWindow(^NeuWindow);
  3084.    if VWindow=NIL then exit;
  3085.    PName:='';
  3086.    SetRGB4(^MyScreen[2]^.ViewPort,1,15,15,15);
  3087.    SetRGB4(^MyScreen[2]^.ViewPort,2,3,3,15);
  3088.    SetRGB4(^MyScreen[2]^.ViewPort,3,9,9,9);
  3089.    WRITE(320,100,1,16,MyScreen[2]^,4,'Neuer Highscore!');
  3090.    if not MultiPlayer then WRITE(320,150,2,16,MyScreen[2]^,4,'Bitte Namen eingeben:') else begin
  3091.       s:='Spieler '+intstr(Save.CivPlayer[ActPlayer])+', bitte Namen eingeben:';
  3092.       WRITE(320,150,2,16,MyScreen[2]^,4,s)
  3093.    end;
  3094.    MAKEBORDER(MyScreen[2]^,100,200,540,230,1,3,0);
  3095.    ScreenToFront(MyScreen[2]);
  3096.    repeat
  3097.       IMsg:=Wait_Port(VWindow^.UserPort);
  3098.       if IMsg<>NIL then begin
  3099.          IMsg:=Get_Msg(VWindow^.UserPort);
  3100.          if IMsg^.Class=VANILLAKEY then VKey:=IMsg^.Code;
  3101.          Reply_Msg(IMsg);
  3102.       end;
  3103.       if (VKey=8) and (PName<>'') then begin
  3104.          PName[length(PName)]:=chr(0);
  3105.          RECT(MyScreen[2]^,0,102,202,538,228);
  3106.       end;
  3107.       if VKey>30 then PName:=PName+chr(VKey);
  3108.       WRITE(320,208,2,17,MyScreen[2]^,4,PName)
  3109.    until VKey=13;
  3110.    GETPLAYERNAME:=PName;
  3111.    CloseWindow(VWindow);
  3112. end;
  3113.  
  3114.  
  3115.  
  3116. procedure PLAYERHIGHSCORE(ActPlayer :byte);
  3117.  
  3118. var s   :string;
  3119. var l   :long;
  3120. var i   :byte;
  3121.  
  3122. begin
  3123.    s:=PathStr[5]+'ST/HiScore.dat';
  3124.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  3125.    if FHandle=0 then begin
  3126.       CREATEHIGHSCORE;
  3127.       s:=PathStr[5]+'ST/HiScore.dat';
  3128.       FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  3129.    end;
  3130.    if FHandle<>0 then begin
  3131.       l:=DosRead(FHandle,^HiScore,sizeof(r_Hiscore));
  3132.       if HiScore.Points[8]<Save.ImperatorState[ActPlayer] then with HiScore do begin
  3133.          Points[8]:=Save.ImperatorState[ActPlayer];
  3134.          CivVar[8]:=ActPlayer;
  3135.          Player[8]:=GETCIVNAME(ActPlayer);
  3136.          if not Save.PlayMySelf and (Save.CivPlayer[ActPlayer]<>0)
  3137.           then Player[8]:=GETPLAYERNAME(ActPlayer);
  3138.          for i:=8 downto 2 do if Points[i]>=Points[i-1] then begin
  3139.             exchange(Points[i],Points[i-1]);
  3140.             exchange(CivVar[i],CivVar[i-1]);
  3141.             exchange(Player[i],Player[i-1]);
  3142.          end;
  3143.          l:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  3144.          l:=DosWrite(FHandle,^HiScore,sizeof(r_Hiscore));
  3145.          HIGHSCORE;
  3146.       end;
  3147.       DosClose(FHandle);
  3148.    end;
  3149. end;
  3150.  
  3151.  
  3152.  
  3153. procedure CLICKRECT(XScreen :Screen; Left,Top,Right,Bottom :word; Color :byte);
  3154.  
  3155. begin
  3156.    SetAPen(^XScreen.RastPort,Color); BOX(XScreen,Left+3,Top+3,Right-3,Bottom-3);
  3157.    PLAYSOUND(1,300);
  3158.    SetAPen(^XScreen.RastPort,0);     BOX(XScreen,Left+3,Top+3,Right-3,Bottom-3);
  3159. end;
  3160.  
  3161.  
  3162.  
  3163. procedure DOINFLATION(ActPlayer :byte);
  3164.  
  3165. var j   :byte;
  3166.  
  3167. begin
  3168.    for j:=1 to 42 do Save.ProjectCosts[ActPlayer,j]:=round(Save.ProjectCosts[ActPlayer,j]*INFLATION);
  3169.    for j:=1 to 42 do Save.TechCosts[ActPlayer,j]:=round(Save.TechCosts[ActPlayer,j]*INFLATION);
  3170. end;
  3171.  
  3172.  
  3173.  
  3174. procedure HANDLEKNOWNPLANET(ActSys,Mode :byte; PlanetPtr :ptr);
  3175.  
  3176. var PMoney,PProd                :long;
  3177. var NewProject                  :array [1..25] of string[30];
  3178. var ProjectRounds               :array [1..25] of long;
  3179. var ProjectNum,ProjectType      :array [1..25] of short;
  3180. var i,j                         :integer;
  3181. var l                           :long;
  3182. var Ships,x,y,btx               :byte;
  3183. var DoIt,b                      :boolean;
  3184. var MyShipPtr                   :^r_ShipHeader;
  3185. var MyPlanetHeader              :^r_PlanetHeader;
  3186. var ActPProjects                :^ByteArr42;
  3187.  
  3188.  
  3189. procedure WRITEPROJECTDATA;
  3190.  
  3191. begin
  3192.    with MyPlanetHeader^ do begin
  3193.       RECT(MyScreen[2]^,0,56,426,327,448);
  3194.       RECT(MyScreen[2]^,0,56,399,256,418);
  3195.       l:=0;
  3196.       if ProjectID<>0 then begin
  3197.          if ProjectID>0 then begin
  3198.             s:=Project[ProjectID];
  3199.             l:=XProjectPayed*100 div (XProjectCosts+1);
  3200.          end else case ProjectID of
  3201.             -3: begin
  3202.                    s:='Biosphäre reinigen';
  3203.                    l:=Biosphäre div 2;
  3204.                 end;
  3205.             -2: begin
  3206.                    s:='Infrastruktur reparieren';
  3207.                    l:=Infrastruktur div 2;
  3208.                 end;
  3209.             otherwise begin
  3210.                    s:='Industrieanlagen reparieren';
  3211.                    l:=Industrie div 2;
  3212.             end;
  3213.          end;
  3214.          WRITE(191,430,2,17,MyScreen[2]^,4,s)
  3215.       end;
  3216.       if l>100 then l:=100;   if l<0 then l:=0;
  3217.       s:=intstr(l);
  3218.       while length(s)<3 do s:='0'+s;
  3219.       WRITE(278,402,4,1,MyScreen[2]^,2,s);
  3220.       RECT(MyScreen[2]^,4,56,399,56+l*2,418);
  3221.  
  3222.       RECT(MyScreen[2]^,0,56,307,178,330);
  3223.       y:=0;   {Kreativität}
  3224.       if ActPProjects^[33]>0 then y:=y+1;   if ActPProjects^[35]>0 then y:=y+1;
  3225.       if ActPProjects^[36]>0 then y:=y+1;   if ActPProjects^[38]>0 then y:=y+1;
  3226.       if ActPProjects^[42]>0 then y:=y+1;
  3227.       if y>0 then for i:=1 to y do BltBitMapRastPort(^ImgBitMap8,320,128,^MyScreen[2]^.RastPort,56+pred(i)*25,308,22,22,192);
  3228.  
  3229.       RECT(MyScreen[2]^,0,56,354,178,376);
  3230.       y:=0;   {Produktivität}
  3231.       if ActPProjects^[31]>0 then y:=y+1;   if ActPProjects^[37]>0 then y:=y+1;
  3232.       if ActPProjects^[38]>0 then y:=y+1;   if ActPProjects^[41]>0 then y:=y+1;
  3233.       if ActPProjects^[42]>0 then y:=y+1;
  3234.       if y>0 then for i:=1 to y do BltBitMapRastPort(^ImgBitMap8,320,151,^MyScreen[2]^.RastPort,56+pred(i)*25,354,22,22,192);
  3235.  
  3236.       RECT(MyScreen[2]^,0,359,92,639,511);
  3237.       x:=1; y:=0;
  3238.       for i:=1 to 7 do if Save.ProjectCosts[ActPlayer,i]<=0 then begin
  3239.          if ActPPRojects^[i]>0 then RECT(MyScreen[2]^,4,293+x*67,92+y*66,360+x*67,159+y*66);
  3240.          BltBitMapRastPort(^ImgBitMap8,pred(i)*64,0,^MyScreen[2]^.RastPort,295+x*67,94+y*66,64,64,192);
  3241.          x:=x+1;
  3242.          if x>4 then begin
  3243.             x:=1; y:=y+1;
  3244.          end;
  3245.       end;
  3246.       for i:=25 to 42 do if (ActPProjects^[i]>0) or ((i=39) and (Save.ProjectCosts[ActPlayer,i]<=0)) then begin
  3247.          if i in [25..27] then      BltBitMapRastPort(^ImgBitMap8,(i-18)*64,0,^MyScreen[2]^.RastPort,295+x*67,y*66+94,64,64,192)
  3248.          else if i in [28..37] then BltBitMapRastPort(^ImgBitMap8,(i-28)*64,64,^MyScreen[2]^.RastPort,295+x*67,y*66+94,64,64,192)
  3249.          else                       BltBitMapRastPort(^ImgBitMap8,(i-38)*64,128,^MyScreen[2]^.RastPort,295+x*67,y*66+94,64,64,192);
  3250.          if i in [26..27] then begin
  3251.             s:=intstr(ActPPRojects^[i]);
  3252.             while length(s)<3 do s:='0'+s;
  3253.             WRITE(309+x*67,y*66+141,4,0,MyScreen[2]^,2,s);
  3254.          end else if i in [34,40] then begin
  3255.             s:=intstr(ActPPRojects^[i])+'%';
  3256.             while length(s)<4 do s:='0'+s;
  3257.             WRITE(300+x*67,y*66+141,4,0,MyScreen[2]^,2,s);
  3258.          end;
  3259.          x:=x+1;
  3260.          if x>4 then begin
  3261.             x:=1; y:=y+1;
  3262.          end;
  3263.          if y=6 then exit;
  3264.       end;
  3265.    end;
  3266. end;
  3267.  
  3268.  
  3269. begin
  3270.    SWITCHDISPLAY;
  3271.    MyPlanetHeader:=PlanetPtr;
  3272.    with MyPlanetHeader^ do begin
  3273.       INITSCREEN(SCREEN_PLANET);
  3274.       ActPProjects:=ProjectPtr;
  3275.       for i:=1 to 3 do RECT(MyScreen[2]^,0,56,i*49+52,256,i*49+71);
  3276.       RECT(MyScreen[2]^,0,0,0,639,90);
  3277.       s:='System: '+Save.SystemName[ActSys]; WRITE(5,5,1,1,MyScreen[2]^,4,s);
  3278.       s:='Planet: '+PName;                   WRITE(5,25,1,1,MyScreen[2]^,4,s);
  3279.       s:='Klasse: ';
  3280.       case Class of
  3281.          CLASS_DESERT    : s:=s+'D (ca. 60%';
  3282.          CLASS_HALFEARTH : s:=s+'H (ca. 80%';
  3283.          CLASS_EARTH     : s:=s+'M (ca. 95%';
  3284.          CLASS_ICE       : s:=s+'I (ca. 60%';
  3285.          CLASS_STONES    : s:=s+'T (ca. 75%';
  3286.          CLASS_WATER     : s:=s+'W (ca. 60%';
  3287.          otherwise;
  3288.       end;
  3289.       s:=s+' Besiedlung)';
  3290.       WRITE(5,45,1,1,MyScreen[2]^,4,s);
  3291.       s:='Größe: '+realstr(Size/10,2)+'-facher Erdradius';
  3292.       WRITE(5,65,1,1,MyScreen[2]^,4,s);
  3293.  
  3294.       if Save.ActTech[ActPlayer]>0 then begin
  3295.          s:='Technologie: '+Technology[Save.ActTech[ActPlayer]];
  3296.          WRITE(275,5,1,1,MyScreen[2]^,4,s);
  3297.       end else WRITE(275,5,1,1,MyScreen[2]^,4,'keine Entwicklung');
  3298.  
  3299.       if FirstShip.NextShip<>NIL then begin
  3300.          i:=0;
  3301.          MyShipPtr:=FirstShip.NextShip;
  3302.          repeat
  3303.             if MyShipPtr^.Owner<>0 then i:=i+1;
  3304.             MyShipPtr:=MyShipPtr^.NextShip;
  3305.          until MyShipPtr=NIL;
  3306.          s:='Schiffe im Orbit: '+intstr(i);
  3307.          WRITE(275,45,1,1,MyScreen[2]^,4,s);
  3308.       end;
  3309.       if Ethno<>PFlags and ActPlayerFlag then begin
  3310.          s:='Ethnische Minderheit der '+GETCIVNAME(GETCIVVAR(Ethno));
  3311.          WRITE(275,65,1,1,MyScreen[2]^,4,s);
  3312.       end;
  3313.  
  3314.       RECT(MyScreen[2]^,4,56,101,56+Biosphäre,120);
  3315.       s:=intstr(Biosphäre div 2);     while length(s)<3 do s:='0'+s;
  3316.       WRITE(278,104,4,1,MyScreen[2]^,2,s);
  3317.       l:=5-ActPProjects^[30]-ActPProjects^[31]
  3318.           -ActPProjects^[32]-ActPProjects^[37]
  3319.           -ActPProjects^[42];
  3320.       if l>0 then for i:=1 to l do BltBitMapRastPort(^ImgBitMap8,320,174,^MyScreen[2]^.RastPort,37+i*22,102,19,18,192);
  3321.  
  3322.       RECT(MyScreen[2]^,4,56,150,56+Infrastruktur,169);
  3323.       s:=intstr(Infrastruktur div 2); while length(s)<3 do s:='0'+s;
  3324.       WRITE(278,153,4,1,MyScreen[2]^,2,s);
  3325.       RECT(MyScreen[2]^,4,56,199,56+Industrie,218);
  3326.       s:=intstr(Industrie div 2);     while length(s)<3 do s:='0'+s;
  3327.       WRITE(278,202,4,1,MyScreen[2]^,2,s);
  3328.       s:=intstr(Population);    while length(s)<7 do s:='0'+s;
  3329.       WRITE(59,251,4,1,MyScreen[2]^,2,s);
  3330.       PProd:=11+(ActPProjects^[31]+ActPProjects^[37]
  3331.                +ActPProjects^[38]+ActPProjects^[41]
  3332.                +ActPProjects^[42])*6;
  3333.       PMoney:=round(PProd*(Infrastruktur/17+Industrie/17+Population/17))+1;
  3334.       while PMoney>MAXPMONEY do PMoney:=round(PMoney*0.95);
  3335.  
  3336.       l:=0;
  3337.       WRITEPROJECTDATA;
  3338.       ScreenToFront(MyScreen[2]);
  3339.       repeat
  3340.          delay(RDELAY);
  3341.          l:=l+1;
  3342.          if Mode=1 then begin
  3343.             if l<20 then i:=4 else i:=0;
  3344.             l:=l+1;
  3345.             if l>40 then l:=0;
  3346.             WRITE(278,402,i,1,MyScreen[2]^,2,'100');
  3347.          end;
  3348.  
  3349.          RawCode:=GETRAWCODE;
  3350.  
  3351.          if (LData^ and 64=0) then begin
  3352.             if (IBase^.MouseX in [56..187]) and (IBase^.MouseY in [455..480]) then begin
  3353.                CLICKRECT(MyScreen[2]^,55,455,186,481,2);
  3354.                Mode:=0;
  3355.                j:=1;
  3356.                if Biosphäre<200 then begin
  3357.                   NewProject[j]:='Biosphäre reinigen';
  3358.                   ProjectRounds[j]:=(200-Biosphäre)*PMoney div 9;
  3359.                   ProjectNum[j]:=-3;
  3360.                   ProjectType[j]:=1;
  3361.                   j:=j+1;
  3362.                end;
  3363.                if Infrastruktur<200 then begin
  3364.                   NewProject[j]:='Infrastruktur reparieren';
  3365.                   ProjectRounds[j]:=(200-Infrastruktur)*PMoney div 9;
  3366.                   ProjectNum[j]:=-2;
  3367.                   ProjectType[j]:=1;
  3368.                   j:=j+1;
  3369.                end;
  3370.                if Industrie<200 then begin
  3371.                   NewProject[j]:='Industrieanlagen reparieren';
  3372.                   ProjectRounds[j]:=(200-Industrie)*PMoney div 9;
  3373.                   ProjectNum[j]:=-1;
  3374.                   ProjectType[j]:=1;
  3375.                   j:=j+1;
  3376.                end;
  3377.                Ships:=0;
  3378.                for i:=42 downto 1 do begin
  3379.                   DoIt:=false;
  3380.                   if (Save.TechCosts[ActPlayer,ProjectNeedsTech[i]]<=0)
  3381.                   {Technologie vorhanden }
  3382.                   and ((ActPProjects^[ProjectNeedsProject[i]]>0) or (Save.ProjectCosts[ActPlayer,ProjectNeedsProject[i]]<=0)) then begin
  3383.                   { nötiges Projekt vorhanden }
  3384.                      if (i in [1..7,39]) and (Save.ProjectCosts[ActPlayer,i]>0) then DoIt:=true;
  3385.                      { Großprojekt noch nicht gebaut }
  3386.                      if (i in [25,28..38,40..42]) and (ActPProjects^[i]=0) then DoIt:=true;
  3387.                      { Projekt noch nicht gebaut }
  3388.                      if i in [8..24,26,27] then DoIt:=true;
  3389.                      { sonstige Projekte, können mehrfach gebaut werden }
  3390.                   end;
  3391.                   if DoIt then begin
  3392.                      ProjectRounds[j]:=Save.ProjectCosts[ActPlayer,i];
  3393.                      NewProject[j]:=Project[i];
  3394.                      ProjectNum[j]:=i;
  3395.                      if i in [8..24] then begin
  3396.                         if (Ships>3) then j:=j-1 else begin
  3397.                            Ships:=Ships+1;
  3398.                            ProjectType[j]:=3;
  3399.                            ProjectRounds[j]:=round(ProjectRounds[j]+(ProjectRounds[j]*(Save.Military[ActPlayer]/100)));
  3400.                         end;
  3401.                      end;
  3402.                      if i in [1..7] then ProjectType[j]:=2;
  3403.                      if i>24 then ProjectType[j]:=4;
  3404.                      j:=j+1;
  3405.                   end;
  3406.                end;
  3407.                j:=j-1;
  3408.                Img:=Image(0,0,384,407,7,ptr(IMemA[0]),127,0,NIL);
  3409.                RECT(MyScreen[2]^,0,360,92,639,511);
  3410.                WRITE(365,474,4,1,MyScreen[2]^,4,'Was soll gebaut werden?');
  3411.                for i:=1 to j do begin
  3412.                   WRITE(365,78+i*16,ProjectType[i],1,MyScreen[2]^,3,NewProject[i]);
  3413.                   if ProjectNum[i]>0 then l:=(ProjectRounds[i]-XProjectPayed) div PMoney+1
  3414.                   else l:=ProjectRounds[i] div PMoney +1;
  3415.                   if l<=0 then l:=1;
  3416.                   s:=intstr(l);
  3417.                   while length(s)<7 do s:='0'+s;
  3418.                   WRITE(575,78+i*16,ProjectType[i],1,MyScreen[2]^,3,s);
  3419.                end;
  3420.                btx:=1;
  3421.                ProjectID:=0;
  3422.                l:=0;
  3423.                repeat
  3424.                   delay(RDELAY);
  3425.                   if IBase^.MouseX>365 then begin
  3426.                      i:=(IBase^.MouseY-78) div 16;
  3427.                      if (i<>btx) and (i in [1..j]) then begin
  3428.                         btx:=i;
  3429.                         for i:=1 to j do
  3430.                          if i<>btx then WRITE(365,78+i*16,ProjectType[i],1,MyScreen[2]^,3,NewProject[i])
  3431.                          else WRITE(365,78+i*16,ProjectType[i],5,MyScreen[2]^,3,NewProject[i]);
  3432.                      end;
  3433.                      if (LData^ and 64=0) then begin
  3434.                         PLAYSOUND(1,300);
  3435.                         if (btx>0) then ProjectID:=ProjectNum[btx];
  3436.                      end;
  3437.                   end;
  3438.                until (ProjectID<>0) or (RData^ and 1024=0);
  3439.                if (RData^ and 1024=0) then begin
  3440.                   ProjectID:=0;
  3441.                   PLAYSOUND(1,300);
  3442.                end else begin
  3443.                   XProjectCosts:=ProjectRounds[btx];
  3444.                   if ProjectID>0 then s:=Project[ProjectID];
  3445.                end;
  3446.                WRITEPROJECTDATA;
  3447.             end else if (IBase^.MouseX in [198..328]) and (IBase^.MouseY in [455..480])
  3448.             and (ProjectID>0) then begin
  3449.                CLICKRECT(MyScreen[2]^,197,455,328,481,2);
  3450.                RECT(MyScreen[2]^,0,360,92,639,511);
  3451.                MAKEBORDER(MyScreen[2]^,362,350,635,487,2,32,0);
  3452.                WRITE(498,361,2,16,MyScreen[2]^,4,'Kosten für Projekt:');
  3453.                l:=XProjectCosts-XProjectPayed;
  3454.                if l<0 then l:=0;
  3455.                s:=intstr(l);
  3456.                WRITE(498,382,4,16,MyScreen[2]^,2,s);
  3457.                WRITE(498,403,2,16,MyScreen[2]^,4,'Guthaben:');
  3458.                s:=intstr(Save.Staatstopf[ActPlayer]);
  3459.                WRITE(498,424,4,16,MyScreen[2]^,2,s);
  3460.                MAKEBORDER(MyScreen[2]^,372,450,493,475,2,32,0); WRITE(432,456,2,16,MyScreen[2]^,4,'Kaufen');
  3461.                MAKEBORDER(MyScreen[2]^,503,450,625,475,2,32,0); WRITE(564,456,2,16,MyScreen[2]^,4,'Abbruch');
  3462.                b:=false;
  3463.                repeat
  3464.                   delay(RDELAY);
  3465.                   if (LData^ and 64=0) and (IBase^.MouseX in [372..493])
  3466.                   and (IBase^.MouseY in [450..475]) then begin
  3467.                      CLICKRECT(MyScreen[2]^,372,450,493,475,2);
  3468.                      b:=true;
  3469.                      l:=XProjectCosts-XProjectPayed;
  3470.                      if l<0 then l:=0;
  3471.                      if l>=Save.Staatstopf[ActPlayer] then begin
  3472.                         XProjectPayed:=XProjectPayed+Save.Staatstopf[ActPlayer];
  3473.                         Save.Staatstopf[ActPlayer]:=0;
  3474.                      end else begin
  3475.                         XProjectPayed:=XProjectCosts;
  3476.                         Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-l;
  3477.                      end;
  3478.                   end;
  3479.                   if (RData^ and 1024=0) or ((LData^ and 64=0)
  3480.                   and (IBase^.MouseX in [503..625]) and (IBase^.MouseY in [450..475]))
  3481.                   then begin
  3482.                      CLICKRECT(MyScreen[2]^,503,450,625,475,2);
  3483.                      b:=true;
  3484.                   end;
  3485.                until b;
  3486.                WRITEPROJECTDATA;
  3487.             end;
  3488.          end;
  3489.       until (RData^ and 1024=0) or (RawCode in [64,67,68]);
  3490.       PLAYSOUND(1,300);
  3491.       CLEARINTUITION;
  3492.       ScreenToFront(MyScreen[1]);
  3493.    end;
  3494. end;
  3495.  
  3496.  
  3497.  
  3498. procedure WRITEGALAXYDATA(ActSys,ShipMaxMove :byte);
  3499.  
  3500. var i           :integer;
  3501. var l           :long;
  3502.  
  3503. begin
  3504.    for i:=1 to Save.SYSTEMS do
  3505.     if (IBase^.MouseX in [SystemX[i]-20..SystemX[i]+20])
  3506.     and (IBase^.MouseY in [SystemY[i]-5..SystemY[i]+5])
  3507.     and (LastSystem<>i) then begin
  3508.       LastSystem:=i;
  3509.       RECT(MyScreen[1]^,0,522,9,629,116);
  3510.       WRITE(525,12,12,0,MyScreen[1]^,4,Save.SystemName[i]);
  3511.       if (Save.CivPlayer[ActPlayer]<>0)
  3512.       and not (SystemFlags[ActPlayer,i] and FLAG_KNOWN=0) then begin
  3513.          s:=intstr(SystemHeader[i].Planets)+' Planeten';
  3514.          WRITE(525,29,12,0,MyScreen[1]^,4,s);
  3515.          s:=GETCIVNAME(GETCIVVAR(SystemFlags[1,i] and FLAG_CIV_MASK));
  3516.          WRITE(525,46,SystemFlags[1,i] and FLAG_CIV_MASK,0,MyScreen[1]^,4,s);
  3517.       end else WRITE(525,29,12,0,MyScreen[1]^,4,'unbekannt');
  3518.       if ActSys>0 then begin
  3519.          l:=abs(SystemX[ActSys]-SystemX[i]) + abs(SystemY[ActSys]-SystemY[i]);
  3520.          l:=l div ShipMaxMove;
  3521.          s:=intstr(l);
  3522.          while length(s)<4 do s:='0'+s;
  3523.          WRITE(547,70,8,0,MyScreen[1]^,2,s);
  3524.          WRITE(550,87,12,0,MyScreen[1]^,4,'Jahre');
  3525.       end else if SystemHeader[i].FirstShip.SType=TARGET_STARGATE then WRITE(528,77,12,0,MyScreen[1]^,4,'Stargate')
  3526.    end;
  3527. end;
  3528.  
  3529.  
  3530.  
  3531. function GETTHESOUND(MID :byte):long;
  3532.  
  3533. var l           :long;
  3534.  
  3535. begin
  3536.    GETTHESOUND:=0;
  3537.    if ModMemA[MID]=0 then exit;
  3538.    l:=AllocMem(ModMemL[MID],MEMF_CHIP);
  3539.    GETTHESOUND:=l;
  3540.    if l<>0 then begin
  3541.       CopyMemQuick(ModMemA[MID],l,ModMemL[MID]);
  3542.       RelocModul(l);
  3543.       PlayModule(l);
  3544.    end;
  3545. end;
  3546.  
  3547.  
  3548.  
  3549. procedure SYSTEMINFO(ActSys :byte);
  3550. forward;
  3551.  
  3552.  
  3553.  
  3554. procedure SHIPINFO(ActSys :byte);
  3555.  
  3556. var Step                :byte;
  3557. var ModC                :long;
  3558. var MyShipPtr           :^r_ShipHeader;
  3559. var MyPlanetHeader      :^r_PlanetHeader;
  3560.  
  3561.  
  3562.  
  3563. procedure WRITEDATA;
  3564.  
  3565. var w1,w2,Col1,Col2     :integer;
  3566. var c1,c2,i             :byte;
  3567.  
  3568. begin
  3569.    with MyShipPtr^ do begin
  3570.       Step:=(300 div Shield);
  3571.       RECT(MyScreen[2]^,0,386,296,513,310);
  3572.       WRITE(443-Step*Tactical,297,1,1,MyScreen[2]^,2,'#');
  3573.       Step:=Shield div 3;
  3574.       if Step=0 then Step:=1;
  3575.       Col1:=round((Tactical+Step)*(255/Step));
  3576.       Col2:=round(-(Tactical-Step)*(255/Step));
  3577.       for i:=1 to 8 do begin
  3578.          if Col1<0 then c1:=0 else if Col1>255 then c1:=255 else c1:=Col1;
  3579.          SetRGB32(^MyScreen[2]^.ViewPort, i+5,c1*$1000000,0,0);
  3580.          Col1:=Col1-30;
  3581.  
  3582.          if Col2<0 then c2:=0 else if Col2>255 then c2:=255 else c2:=Col2;
  3583.          SetRGB32(^MyScreen[2]^.ViewPort,i+19,c2*$1000000,0,c2*$1000000);
  3584.          Col2:=Col2-30;
  3585.       end;
  3586.       s:=intstr(Shield+Tactical*3); while length(s)<3 do s:='0'+s;
  3587.       WRITE(275,296,5,1,MyScreen[2]^,2,s);
  3588.       s:=intstr(round((Shield+Tactical*3)/ShipData[SType].MaxShield*100));
  3589.       while length(s)<3 do s:='0'+s;
  3590.       WRITE(324,296,5,1,MyScreen[2]^,2,s);
  3591.  
  3592.       w1:=round((Weapon/10+1)*(ShipData[SType].WeaponPower-Tactical));
  3593.       w2:=round((Weapon/10+1)*ShipData[SType].WeaponPower);
  3594.       s:=intstr(w1);
  3595.       while length(s)<3 do s:='0'+s;
  3596.       WRITE(522,296,5,1,MyScreen[2]^,2,s);
  3597.       s:=intstr(round((w1/w2*100)));
  3598.       while length(s)<3 do s:='0'+s;
  3599.       WRITE(571,296,5,1,MyScreen[2]^,2,s);
  3600.  
  3601.       Step:=111 div ShipData[SType].MaxMove;
  3602.       RECT(MyScreen[2]^,0,386,427,513,442);
  3603.       WRITE(498-Step*Repair,429,1,1,MyScreen[2]^,2,'#');
  3604.  
  3605.       if Repair=0 then s:='999' else
  3606.       if Shield=ShipData[SType].MaxShield then s:='---' else
  3607.       s:=intstr((ShipData[SType].MaxShield-Shield) div Repair);
  3608.  
  3609.       while length(s)<3 do s:='0'+s;
  3610.       WRITE(337,428,5,1,MyScreen[2]^,2,s);
  3611.       s:=intstr(ShipData[SType].MaxMove-Repair); while length(s)<3 do s:='0'+s;
  3612.       WRITE(522,428,5,1,MyScreen[2]^,2,s);
  3613.    end;
  3614. end;
  3615.  
  3616.  
  3617. begin
  3618.    MyShipPtr:=ObjPtr;
  3619.    if not (MyShipPtr^.SType in [8..24]) or (MyShipPtr^.Owner<>ActPlayerFlag) then exit;
  3620.    ModC:=GETTHESOUND(3);
  3621.    INITSCREEN(SCREEN_TECH);
  3622.    s:=PathStr[6]+'ST/'+Project[MyShipPtr^.SType]+'Tech.img';
  3623.    if not DISPLAYIMAGE(s,6,7,256,498,5,MyScreen[2]^,0) then begin end;
  3624.    with MyShipPtr^ do begin
  3625.  
  3626.       WRITE(290,15,1,0,MyScreen[2]^,4,Project[MyShipPtr^.SType]);
  3627.       case Weapon of
  3628.          WEAPON_GUN:       s:='Feuerwaffen';
  3629.          WEAPON_LASER:     s:='Laserkanonen';
  3630.          WEAPON_PHASER:    s:='Phaserbänke';
  3631.          WEAPON_DISRUPTOR: s:='Disruptorbänke';
  3632.          WEAPON_PTORPEDO:  s:='Protonentorpedo-Slots';
  3633.          otherwise s:=intstr(Weapon);
  3634.       end;
  3635.       s:='- Bewaffnung:  '+s;
  3636.       WRITE(290,42,1,0,MyScreen[2]^,3,s);
  3637.       s:='- Angriffsstärke:  '+intstr(round(ShipData[SType].WeaponPower*(Weapon/10+1)));
  3638.       WRITE(290,62,1,0,MyScreen[2]^,3,s);
  3639.       s:='- Schilde:  '+intstr(ShipData[SType].MaxShield);
  3640.       WRITE(290,82,1,0,MyScreen[2]^,3,s);
  3641.       s:='- Kampferfahrung:  '+intstr(ShieldBonus);
  3642.       WRITE(290,102,1,0,MyScreen[2]^,3,s);
  3643.       s:='- Zustand des Schiffes:  '+realstr(Shield/ShipData[SType].MaxShield*100,2)+' %';
  3644.       WRITE(290,122,1,0,MyScreen[2]^,3,s);
  3645.       s:='- Bewegungsrate:  '+intstr(ShipData[SType].MaxMove);
  3646.       WRITE(290,142,1,0,MyScreen[2]^,3,s);
  3647.       s:='- Siedler an Bord:  '+intstr((Ladung and MASK_SIEDLER) div 16);
  3648.       WRITE(290,162,1,0,MyScreen[2]^,3,s);
  3649.       s:='- Landungstrupps an Bord:  '+intstr(Ladung and MASK_LTRUPPS);
  3650.       WRITE(290,182,1,0,MyScreen[2]^,3,s);
  3651.       s:='- Frachträume zu '+intstr(round(Fracht / ShipData[Stype].MaxLoad*100))+'% belegt';
  3652.       WRITE(290,202,1,0,MyScreen[2]^,3,s);
  3653.       s:='- Baujahr: ';
  3654.       if Age<200 then s:=s+intstr(Year-Age) else s:=s+' Schiff ist völlig veraltet!!';
  3655.       WRITE(290,222,1,0,MyScreen[2]^,3,s);
  3656.  
  3657.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(MyShipPtr^.Target)*sizeof(r_PlanetHeader));
  3658.       WRITEDATA;
  3659.       ScreenToFront(MyScreen[2]);
  3660.       repeat
  3661.          delay(RDELAY);
  3662.          if (LData^ and 64=0) then begin
  3663.             PLAYSOUND(1,300);
  3664.             if IBase^.MouseY in [455..480] then begin
  3665.                if (IBase^.MouseX in [380..410]) and (Repair<ShipData[SType].MaxMove) then Repair:=Repair+1;
  3666.                if (IBase^.MouseX in [490..525]) and (Repair>0) then Repair:=Repair-1;
  3667.                WRITEDATA;
  3668.             end;
  3669.             if IBase^.MouseY in [315..345] then begin
  3670.                if (IBase^.MouseX in [380..410])
  3671.                 and (Tactical<ShipData[SType].WeaponPower-2)
  3672.                 and (3*Tactical<Shield-2) then Tactical:=Tactical+1;
  3673.                if (IBase^.MouseX in [490..525])
  3674.                 and (-3*Tactical<Shield-2)
  3675.                 and (-Tactical<ShipData[SType].WeaponPower-2) then Tactical:=Tactical-1;
  3676.                WRITEDATA;
  3677.             end;
  3678.          end;
  3679.       until (RData^ and 1024=0);
  3680.    end;
  3681.    if ModC<>0 then begin
  3682.       StopPlayer;
  3683.       FreeMem(ModC,ModMemL[3]);
  3684.    end;
  3685.    PLAYSOUND(1,300);
  3686.    ScreenToFront(MyScreen[1]);
  3687. end;
  3688.  
  3689.  
  3690.  
  3691. procedure CHECKPROJECTS(PlanetPtr :ptr; NewOwner :byte);
  3692.  
  3693. var MyPlanetHeader      :^r_PlanetHeader;
  3694. var ActPProject         :^ByteArr42;
  3695. var i                   :byte;
  3696.  
  3697. begin
  3698.    MyPlanetHeader:=PlanetPtr;
  3699.    ActPProject:=MyPlanetHeader^.ProjectPtr;
  3700.    for i:=1 to 7 do if ActPProject^[i]>0 then with MyPlanetHeader^ do begin
  3701.       Save.ProjectCosts[GETCIVVAR(NewOwner),i]:=0;
  3702.       Save.ProjectCosts[GETCIVVAR(PFlags),i]:=abs(Year)*i*11;
  3703.       if (Save.CivPlayer[GETCIVVAR(PFlags)]<>0) or (Save.CivPlayer[GETCIVVAR(NewOwner)]<>0) then begin
  3704.          MAKEBORDER(MyScreen[1]^,85,118,425,200,12,6,0);
  3705.          s:=GETCIVNAME(GETCIVVAR(PFlags))+' verlieren';
  3706.          WRITE(256,130,PFlags and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  3707.          s:=Project[i]+'-';
  3708.          WRITE(256,150,12,1+16,MyScreen[1]^,4,s);
  3709.          s:='Projekt an '+GETCIVNAME(GETCIVVAR(NewOwner));
  3710.          WRITE(256,171,NewOwner and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  3711.          if Save.PlayMySelf then delay(PAUSE);
  3712.          WAITLOOP(Save.PlayMySelf);
  3713.          RECT(MyScreen[1]^,0,85,118,425,200);
  3714.       end;
  3715.    end;
  3716. end;
  3717.  
  3718.  
  3719.  
  3720. procedure SYSTEMTOENEMY(ActSys,NewOwner,OldOwner :byte);
  3721.  
  3722. var i                   :byte;
  3723. var MyPlanetHeader      :^r_PlanetHeader;
  3724. var MyShipPtr           :^r_ShipHeader;
  3725.  
  3726.  
  3727. begin
  3728.    for i:=0 to pred(SystemHeader[ActSys].Planets) do begin
  3729.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+i*sizeof(r_PlanetHeader));
  3730.       with MyPlanetHeader^ do if PFlags and FLAG_CIV_MASK=OldOwner then  begin
  3731.          CHECKPROJECTS(MyPlanetHeader,NewOwner);
  3732.          PFlags:=NewOwner;
  3733.          MyShipPtr:=FirstShip.NextShip;
  3734.          while MyShipPtr<>NIL do begin
  3735.             MyShipPtr^.PosX:=round(PosX);
  3736.             MyShipPtr^.PosY:=round(PosY);
  3737.             LINKSHIP(MyShipPtr,^SystemHeader[ActSys].FirstShip,1);
  3738.             MyShipPtr:=FirstShip.NextShip;
  3739.          end;
  3740.       end;
  3741.    end;
  3742. end;
  3743.  
  3744.  
  3745.  
  3746. procedure PLAYERJINGLE(JingleID :byte);
  3747.  
  3748. var l           :long;
  3749. var Fname       :string;
  3750.  
  3751. begin
  3752.    if LogoSMemA[JingleID]=0 then begin
  3753.       FName:=PathStr[10]+'ST/'+intstr(JingleID)+'.RAW';
  3754.       FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  3755.       if FHandle=0 then exit;
  3756.       l:=DosSeek(FHandle,0,OFFSET_END);
  3757.       LogoSMemL[JingleID]:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  3758.       LogoSMemA[JingleID]:=AllocMem(LogoSMemL[JingleID],MEMF_FAST+MEMF_CLEAR);
  3759.       if LogoSMemA[JingleID]=0 then begin
  3760.          DosClose(FHandle);   exit;
  3761.       end;
  3762.       l:=DosRead(FHandle,ptr(LogoSMemA[JingleID]),LogoSMemL[JingleID]);
  3763.       DosClose(FHandle);
  3764.    end;
  3765.    if (SoundMemA[4]=0) or (SoundSize[4]*2<>LogoSMemL[JingleID]) then begin
  3766.       if SoundSize[4]<>0 then FreeMem(SoundMemA[4],SoundSize[4]*2);
  3767.       SoundSize[4]:=LogoSMemL[JingleID] div 2;
  3768.       SoundMemA[4]:=AllocMem(SoundSize[4]*2,MEMF_CHIP+MEMF_CLEAR);
  3769.       if SoundMemA[4]=0 then exit;
  3770.    end;
  3771.    CopyMemQuick(LogoSMemA[JingleID],SoundMemA[4],LogoSMemL[JingleID]);
  3772.    PLAYSOUND(4,300);
  3773. end;
  3774.  
  3775.  
  3776.  
  3777. procedure DISPLAYLOGO(ActPlayer :byte; Ledge,TEdge :word);
  3778.  
  3779. var FName               :string;
  3780. var ISize,l,ActMem      :long;
  3781.  
  3782. begin
  3783.    if LogoMemA[0]=0 then LogoMemA[0]:=AllocMem(LOGOSIZE,MEMF_CHIP+MEMF_CLEAR);
  3784.    if LogoMemA[0]<>0 then begin
  3785.       if LogoMemA[ActPlayer]=0 then begin
  3786.          LogoMemA[ActPlayer]:=AllocMem(LOGOSIZE,MEMF_FAST+MEMF_CLEAR);
  3787.          ActMem:=LogoMemA[ActPlayer];
  3788.          if ActMem=0 then ActMem:=LogoMemA[0];
  3789.          FName:=PathStr[11]+'ST/'+intstr(ActPlayer)+'.img';
  3790.          FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  3791.          if FHandle<>0 then begin
  3792.             ISize:=DosSeek(FHandle,0,OFFSET_END);
  3793.             ISize:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  3794.             l:=DosRead(FHandle,ptr(ActMem+LOGOSIZE-ISize-150),ISize);
  3795.             UNPACK(ActMem,ActMem+LOGOSIZE-ISize-150,14336,1);
  3796.             DosClose(FHandle);
  3797.          end;
  3798.       end;
  3799.       if LogoMemA[ActPlayer]>0 then CopyMemQuick(LogoMemA[ActPlayer],LogoMemA[0],LOGOSIZE);
  3800.       Img:=Image(0,0,128,128,7,ptr(LogoMemA[0]),127,0,NIL);
  3801.       DrawImage(^MyScreen[1]^.RastPort,^Img,LEdge,TEdge);
  3802.    end;
  3803. end;
  3804.  
  3805.  
  3806.  
  3807. procedure INFORMUSER;
  3808.  
  3809. begin
  3810.    if (Save.CivPlayer[ActPlayer]=0) or Informed or
  3811.    (Save.WarState[ActPlayer,ActPlayer]=LEVEL_DIED) then exit;
  3812.    Informed:=true;
  3813.    if LastPlayer=ActPlayer then exit;
  3814.    LastPlayer:=ActPlayer;
  3815.    Display:=LastDisplay[ActPlayer];
  3816.    RECT(MyScreen[1]^,0,523,10,630,117);
  3817.    if Multiplayer or (Year=1900) then begin
  3818.       if not Save.PlayMySelf then RECT(MyScreen[1]^,0,0,0,511,511);
  3819.       s:='Spieler '+intstr(Save.CivPlayer[ActPlayer]);
  3820.       PLAYERJINGLE(ActPlayer);
  3821.       MAKEBORDER(MyScreen[1]^,35,80,475,290,12,6,0);
  3822.       if Year>1900 then
  3823.        WRITE(256,100,12,16,MyScreen[1]^,4,'Nächster am Zug:')
  3824.       else begin
  3825.          case ActPlayerFlag of
  3826.             FLAG_TERRA:  WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Föderation der Planeten:');
  3827.             FLAG_KLEGAN: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Klingonisches Reich:');
  3828.             FLAG_REMALO: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Romulanisches Imperium:');
  3829.             FLAG_CARDAC: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Kardassianisches Zentralkommando:');
  3830.             FLAG_FERAGI: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Ferengi-Allianz:');
  3831.             FLAG_BAROJA: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Bajoraner:');
  3832.             FLAG_VOLKAN: WRITE(256,100,ActPlayerFlag,16,MyScreen[1]^,4,'Vulkanier:');
  3833.          end;
  3834.       end;
  3835.       WRITE(256,125,ActPlayerFlag,16,MyScreen[1]^,4,s);
  3836.       DISPLAYLOGO(ActPlayer,192,150);
  3837.       PRINTGLOBALINFOS(ActPlayer);
  3838.       if Save.PlayMySelf then delay(PAUSE);
  3839.       WAITLOOP(Save.PlayMySelf);
  3840.       if Display=0 then DRAWSTARS(MODE_REDRAW,ActPlayer) else DRAWSYSTEM(MODE_REDRAW,Display,NIL);
  3841.    end;
  3842. end;
  3843.  
  3844.  
  3845.  
  3846. procedure CHECKPLANET(MyPlanetHeader :PlanetHeader);
  3847.  
  3848. var HomeWorld,SplitWorld,i,j :byte;
  3849. var MyShipPtr                :ShipHeader;
  3850.  
  3851. begin
  3852.    HomeWorld:=0;
  3853.    with MyPlanetHeader^ do for i:=1 to (MAXCIVS-2) do
  3854.    if (PNames[i,3]=PName) and (GETCIVVAR(PFlags)=i) then HomeWorld:=i;
  3855.    if HomeWorld>0 then begin
  3856.       {*** Eroberte Civi abspalten ***}
  3857.       SplitWorld:=0;
  3858.       for i:=1 to Save.SYSTEMS do begin
  3859.          for j:=1 to SystemHeader[i].Planets do begin
  3860.             MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  3861.             with MyPlanetHeader^ do if GETCIVVAR(PFlags)=HomeWorld then begin
  3862.                if (SplitWorld=0) and (Ethno<>PFlags and FLAG_CIV_MASK) then begin
  3863.                   if Ethno<>PFlags and FLAG_CIV_MASK then SplitWorld:=Ethno;
  3864.                   if Save.CivPlayer[ActPlayer]<>0 then begin
  3865.                      INFORMUSER;
  3866.                      MAKEBORDER(MyScreen[1]^,80,120,430,250,12,6,0);
  3867.                      WRITE(256,136,GETCIVFLAG(HomeWorld),1+16,MyScreen[1]^,4,'Der Fall der Heimatwelt der');
  3868.                      s:=GETCIVNAME(HomeWorld)+' verursacht eine Spaltung';
  3869.                      WRITE(256,156,GETCIVFLAG(HomeWorld),1+16,MyScreen[1]^,4,s);
  3870.                      WRITE(256,176,GETCIVFLAG(HomeWorld),1+16,MyScreen[1]^,4,'des Imperiums in einen loyalen Teil');
  3871.                      WRITE(256,196,SplitWorld,1+16,MyScreen[1]^,4,'und einen aufständischen,');
  3872.                      s:=GETCIVADJ(GETCIVVAR(Splitworld))+'n Teil!';
  3873.                      WRITE(256,216,SplitWorld,1+16,MyScreen[1]^,4,s);
  3874.                      if Save.PlayMySelf then begin
  3875.                         delay(PAUSE); delay(PAUSE);
  3876.                      end;
  3877.                      WAITLOOP(Save.PlayMySelf);
  3878.                      RECT(MyScreen[1]^,0,80,120,430,250);
  3879.                   end;
  3880.                end;
  3881.                if SplitWorld=Ethno then begin
  3882.                   PFlags:=Ethno;
  3883.                   if FirstShip.NextShip<>NIL then begin
  3884.                      MyShipPtr:=FirstShip.NextShip;
  3885.                      repeat
  3886.                         MyShipPtr^.Owner:=(PFlags and FLAG_CIV_MASK);
  3887.                         MyShipPtr:=MyShipPtr^.NextShip;
  3888.                      until MyShipPtr=NIL;
  3889.                   end;
  3890.                end;
  3891.             end;
  3892.          end;
  3893.       end;
  3894.    end;
  3895. end;
  3896.  
  3897.  
  3898.  
  3899. function GETCNUM(Depth :byte):byte;
  3900.  
  3901. var i,j   :integer;
  3902.  
  3903. begin
  3904.    j:=1;
  3905.    for i:=1 to Depth do j:=j*2;
  3906.    GETCNUM:=j-1;
  3907. end;
  3908.  
  3909.  
  3910.  
  3911. procedure REQUEST(s1,s2 :str; c1,c2 :byte);
  3912.  
  3913. begin
  3914.    MAKEBORDER(MyScreen[1]^,35,110,475,190,12,6,0);
  3915.    WRITE(256,130,c1,16,MyScreen[1]^,4,s1);
  3916.    WRITE(256,155,c2,16,MyScreen[1]^,4,s2);
  3917.    if Save.PlayMySelf then delay(PAUSE);
  3918.    WAITLOOP(Save.PlayMySelf);
  3919.    RECT(MyScreen[1]^,0,35,110,475,190);
  3920.    REFRESHDISPLAY;
  3921. end;
  3922.  
  3923.  
  3924.  
  3925. procedure STOPCIVILWAR(EndText :byte);
  3926.  
  3927. var CivVar,CivFlag,i,j  :byte;
  3928. var s                   :string;
  3929. var MyPlanetHeader      :PlanetHeader;
  3930. var MyShipPtr           :ShipHeader;
  3931. var ModC,ModL           :long;
  3932.  
  3933. begin
  3934.    ModC:=0;
  3935.    if Save.WorldFlag in [0,WFLAG_CEBORC,WFLAG_FIELD,WFLAG_DCON,WFLAG_JAHADR] then exit;
  3936.    INFORMUSER;
  3937.    CivVar:=GETCIVVAR(Save.WorldFlag);
  3938.    CivFlag:=Save.WorldFlag;
  3939.    Save.WorldFlag:=0;
  3940.    Save.Bevölkerung[8]:=0; Save.WarPower[8]:=0;
  3941.    Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]+Save.Staatstopf[8];
  3942.    Save.Staatstopf[8]:=0;
  3943.    if Save.CivPlayer[CivVar]<>0 then begin
  3944.       ModC:=GETTHESOUND(2);
  3945.       ModL:=ModMemL[2];
  3946.    end;
  3947.    if EndText=0 then begin
  3948.       s:='Die '+GETCIVNAME(CivVar)+' beenden den Bürgerkrieg und';
  3949.       if Save.CivPlayer[CivVar]<>0 then REQUEST(s,'vereinigen ihr Imperium wieder!',CivFlag,CivFlag);
  3950.    end else if EndText=1 then begin
  3951.       {REBELLEN-SIEG}
  3952.       if Save.CivPlayer[CivVar]<>0 then case CivFlag of
  3953.          FLAG_TERRA:  REQUEST('Die Sternenflotte kapituliert vor den Rebellen',
  3954.                               'und übergibt die Macht über die Föderation.',CivFlag,CivFlag);
  3955.          FLAG_KLEGAN: REQUEST('Das Militär kapituliert vor dem Hause der Duras und',
  3956.                               'übergibt die Macht über das klingonische Reich.',CivFlag,CivFlag);
  3957.          FLAG_REMALO: REQUEST('Das Militär kapituliert vor den Talshiar und',
  3958.                               'übergibt die Macht über das Imperium.',CivFlag,CivFlag);
  3959.          FLAG_CARDAC: REQUEST('Das Militär kapituliert vor dem obsidianischen',
  3960.                               'Orden und übergibt die Macht im Zentralkommando.',CivFlag,CivFlag);
  3961.          FLAG_FERAGI: REQUEST('Das Militär kapituliert vor den Rebellen',
  3962.                               'und übergibt die Macht über die Ferengiallianz.',CivFlag,CivFlag);
  3963.          otherwise REQUEST('Die Militärführung kapituliert vor den Rebellen',
  3964.                            'und übergibt das Kommando über das Imperium.',CivFlag,CivFlag);
  3965.       end;
  3966.       for i:=1 to MAXCIVS-2 do if i<>CivVar then begin
  3967.          Save.WarState[i,CivVar]:=Save.WarState[i,8];
  3968.          Save.WarState[CivVar,i]:=Save.WarState[8,i];
  3969.       end;
  3970.    end else if EndText=2 then if Save.CivPlayer[CivVar]<>0 then begin
  3971.       {MILITÄR-SIEG}
  3972.       s:='Die Rebellen kapitulieren und stimmen der';
  3973.       if Save.CivPlayer[CivVar]<>0 then case CivFlag of
  3974.          FLAG_TERRA:  REQUEST(s,'Reintegration in die Föderation zu.',CivFlag,CivFlag);
  3975.          FLAG_KLEGAN: REQUEST('Die Duras kapitulieren und stimmen der','Reintegration in das Reich zu.',CivFlag,CivFlag);
  3976.          FLAG_REMALO: REQUEST('Die Talshiar kapitulieren und stimmen','der Reintegration in das Imperium zu.',CivFlag,CivFlag);
  3977.          FLAG_CARDAC: REQUEST('Der obsidianische Orden kapituliert und','stimmt der reintegration zu.',CivFlag,CivFlag);
  3978.          FLAG_FERAGI: REQUEST(s,'Reintegration in die Ferengiallianz zu.',CivFlag,CivFlag);
  3979.          otherwise REQUEST('Die Rebellen kapitulieren und stimmen der','Reintegration in das Imperium zu.',CivFlag,CivFlag);
  3980.       end;
  3981.    end;
  3982.    for i:=1 to pred(MAXCIVS) do begin
  3983.       Save.WarState[i,8]:=LEVEL_UNKNOWN;
  3984.       Save.WarState[8,i]:=LEVEL_UNKNOWN
  3985.    end;
  3986.    for i:=1 to 42 do if Save.TechCosts[8,i]<=0 then Save.TechCosts[CivVar,i]:=0;
  3987.    for i:=1 to Save.SYSTEMS do begin
  3988.       if (SystemFlags[1,i] and FLAG_CIV_MASK=FLAG_OTHER)
  3989.        then SystemFlags[1,i]:=SystemFlags[1,i] and not FLAG_OTHER or CivFlag;
  3990.       with SystemHeader[i] do if FirstShip.NextShip<>NIL then begin
  3991.          MyShipPtr:=FirstShip.NextShip;
  3992.          repeat
  3993.             if MyShipPtr^.Owner=FLAG_OTHER then begin
  3994.                if random(100)<15 then begin
  3995.                   MyShipPtr^.Owner:=FLAG_MAQUES;
  3996.                   MyShipPtr^.Flags:=0;
  3997.                   MyShipPtr^.Target:=0;
  3998.                end else begin
  3999.                   MyShipPtr^.Owner:=CivFlag;
  4000.                   Save.WarPower[CivVar]:=Save.WarPower[CivVar]+round(ShipData[MyShipPtr^.SType].WeaponPower*(MyShipPtr^.Weapon/10+1));
  4001.                end;
  4002.             end;
  4003.             MyShipPtr:=MyShipPtr^.NextShip;
  4004.          until MyShipPtr=NIL;
  4005.       end;
  4006.       for j:=1 to SystemHeader[i].Planets do begin
  4007.          MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  4008.          with MyPlanetHeader^ do if GETCIVVAR(PFlags)=8 then begin
  4009.             PFlags:=CivFlag;
  4010.             if (Ethno and FLAG_CIV_MASK=FLAG_OTHER) then Ethno:=PFlags;
  4011.             Save.Bevölkerung[CivVar]:=Save.Bevölkerung[CivVar]+Population;
  4012.             if FirstShip.NextShip<>NIL then begin
  4013.                MyShipPtr:=FirstShip.NextShip;
  4014.                repeat
  4015.                   MyShipPtr^.Owner:=CivFlag;
  4016.                   Save.WarPower[CivVar]:=Save.WarPower[CivVar]+round(ShipData[MyShipPtr^.SType].WeaponPower*(MyShipPtr^.Weapon/10+1));
  4017.                   MyShipPtr:=MyShipPtr^.NextShip;
  4018.                until MyShipPtr=NIL;
  4019.             end;
  4020.          end;
  4021.       end;
  4022.    end;
  4023.    REFRESHDISPLAY;
  4024.    SETWORLDCOLORS;
  4025.    if ModC<>0 then begin
  4026.       StopPlayer;
  4027.       FreeMem(ModC,ModL);
  4028.    end;
  4029. end;
  4030.  
  4031.  
  4032.  
  4033. procedure DISPLAYTECH(TechID,CivVar :byte);
  4034.  
  4035. var s                   :string[50];
  4036. var Depth               :byte;
  4037. var l,Offset,ModC       :long;
  4038.  
  4039. begin
  4040.    if TechID=0 then exit;
  4041.    SWITCHDISPLAY;
  4042.    ModC:=GETTHESOUND(1);
  4043.    IMemID:=false;
  4044.    RECT(MyScreen[2]^,0,0,0,639,511);
  4045.    s:=Technology[TechID]+'.pal';
  4046.    if TechID=34 then s:='selbstSys.pal';
  4047.    if      TechID in [1..18]  then s:=PathStr[2]+s
  4048.    else if TechID in [19..38] then s:=PathStr[3]+s
  4049.    else if TechID in [39..42] then s:=PathStr[4]+s;
  4050.    Depth:=SETCOLOR(MyScreen[2]^,s);
  4051.    if Depth=0 then begin
  4052.       s:=PathStr[2]+'NoPic.pal';
  4053.       Depth:=SETCOLOR(MyScreen[2]^,s);
  4054.    end;
  4055.    s[length(s)-3]:=chr(0);
  4056.    s:=s+'.img';
  4057.    if not DISPLAYIMAGE(s,0,40,320,256,Depth,MyScreen[2]^,0) then begin end;
  4058.  
  4059.    WRITE(340,50,1,0,MyScreen[2]^,3,'Wissenschaftler entdecken neue Technologie:');
  4060.    WRITE(340,70,1,0,MyScreen[2]^,4,Technology[TechID]);
  4061.    if TechUse1[TechID]>0 then begin
  4062.       WRITE(340,110,1,0,MyScreen[2]^,4,'Benötigt:');
  4063.       WRITE(370,130,1,0,MyScreen[2]^,4,Technology[TechUse1[TechID]]);
  4064.       if TechUse1[TechID]<>TechUse2[TechID] then WRITE(370,150,1,0,MyScreen[2]^,4,Technology[TechUse2[TechID]]);
  4065.    end;
  4066.    if TechID<>27 then begin
  4067.       WRITE(340,190,1,0,MyScreen[2]^,4,'Ermöglicht:');
  4068.       l:=0;
  4069.       for CivVar:=1 to 42 do if TechUse1[CivVar]=TechID then l:=CivVar;
  4070.       for CivVar:=1 to 42 do if TechUse2[CivVar]=TechID then Offset:=CivVar;
  4071.       if l>0 then WRITE(370,210,1,0,MyScreen[2]^,4,Technology[l]);
  4072.       if (l<>Offset) and (Offset in [1..42]) then WRITE(370,230,1,0,MyScreen[2]^,4,Technology[Offset]);
  4073.    end;
  4074.    l:=320;
  4075.    for CivVar:=1 to 42 do if ProjectNeedsTech[CivVar]=TechID then begin
  4076.       if CivVar in [1..7] then s:='Großprojekt:'
  4077.       else if CivVar in [8..24] then s:='Raumschiff:'
  4078.       else s:='Bauprojekt:';
  4079.       s:=s+'  '+Project[CivVar];
  4080.       WRITE(20,l,1,0,MyScreen[2]^,4,s);
  4081.       l:=l+20;
  4082.    end;
  4083.    Screen2:=SCREEN_INVENTION;
  4084.    ScreenToFront(MyScreen[2]);
  4085.    if Save.PlayMySelf then delay(PAUSE*2);
  4086.    WAITLOOP(Save.PlayMySelf);
  4087.    if ModC<>0 then begin
  4088.       StopPlayer;
  4089.       FreeMem(ModC,ModMemL[1]);
  4090.    end;
  4091.    ScreenToFront(MyScreen[1]);
  4092. end;
  4093.  
  4094.  
  4095.  
  4096.  
  4097. function TAKETECH(CivFlag1,CivFlag2 :byte):boolean;
  4098.  
  4099. var i,TechID,CivVar1,CivVar2    :byte;
  4100.  
  4101. begin
  4102.    TAKETECH:=false;
  4103.    CivVar1:=GETCIVVAR(CivFlag1);
  4104.    CivVar2:=GETCIVVAR(CivFlag2);
  4105.    TechID:=0;
  4106.    for i:=41 downto 1 do
  4107.     if ((Save.TechCosts[CivVar1,i]>0) and (Save.TechCosts[CivVar2,i]<=0)) then TechID:=i;
  4108.    if TechID=0 then exit;
  4109.    if ((CivVar1=ActPlayer) or (CivVar2=ActPlayer))
  4110.    and ((Save.CivPlayer[CivVar1]<>0) or (Save.CivPlayer[CivVar2]<>0)) then begin
  4111.       MAKEBORDER(MyScreen[1]^,85,118,425,200,12,6,0);
  4112.       s:=GETCIVNAME(CivVar1)+' übernehmen Technologie:';
  4113.       WRITE(256,140,CivFlag1,1+16,MyScreen[1]^,4,s);
  4114.       s:=Technology[TechID];
  4115.       WRITE(256,160,12,1+16,MyScreen[1]^,4,s);
  4116.       if Save.PlayMySelf then delay(PAUSE);
  4117.       WAITLOOP(Save.PlayMySelf);
  4118.       RECT(MyScreen[1]^,0,85,118,425,200);
  4119.       REFRESHDISPLAY;
  4120.       if (CivFlag1=ActPlayerFlag) then DISPLAYTECH(TechID,CivVar1);
  4121.    end;
  4122.    Save.TechCosts[CivVar1,TechID]:=0;
  4123.    if Save.ActTech[CivVar1]=TechID then Save.ActTech[CivVar1]:=0;
  4124.    TAKETECH:=true;
  4125. end;
  4126.  
  4127.  
  4128.  
  4129. procedure PEACEINFO(CivVar1,CivVar2,CivFlag1,CivFlag2 :byte);
  4130.  
  4131. var s   :string;
  4132.  
  4133. begin
  4134.    INFORMUSER;
  4135.    MAKEBORDER(MyScreen[1]^,85,120,425,220,12,6,0);
  4136.    s:=GETCIVNAME(CivVar1);
  4137.    WRITE(256,132,CivFlag1,1+16,MyScreen[1]^,4,s);
  4138.    WRITE(256,152,12,1+16,MyScreen[1]^,4,'und');
  4139.    s:=GETCIVNAME(CivVar2);
  4140.    WRITE(256,172,CivFlag2,1+16,MyScreen[1]^,4,s);
  4141.    WRITE(256,192,12,1+16,MyScreen[1]^,4,'schließen Frieden');
  4142.    if Save.PlayMySelf then delay(PAUSE);
  4143.    WAITLOOP(Save.PlayMySelf);
  4144.    RECT(MyScreen[1]^,0,85,120,425,220);
  4145.    REFRESHDISPLAY;
  4146.    if (Save.WorldFlag in [CivFlag1,CivFlag2])
  4147.     and ((CivVar1=8) or (CivVar2=8)) then STOPCIVILWAR(0);
  4148. end;
  4149.  
  4150.  
  4151.  
  4152. procedure SYSINFO(SysID,ThePlayerFlag :byte);
  4153.  
  4154. var MyPlanetHeader      :^r_PlanetHeader;
  4155. var ActPProject         :^ByteArr42;
  4156. var SysPop,Buildings    :long;
  4157. var MyPlanets           :byte;
  4158. var j,i                 :byte;
  4159. var s                   :string;
  4160.  
  4161. begin
  4162.    RECT(MyScreen[1]^,0,30,250,480,360);
  4163.    if SysID=0 then exit;
  4164.    SysPop:=0; MyPlanets:=0; Buildings:=0;
  4165.    with SystemHeader[SysID] do for i:=0 to pred(Planets) do begin
  4166.       MyPlanetHeader:=ptr(PlanetMemA+i*sizeof(r_PlanetHeader));
  4167.       with MyPlanetHeader^ do if (PFlags and FLAG_CIV_MASK=ThePlayerFlag) then begin
  4168.          SysPop:=SysPop+Population;
  4169.          MyPlanets:=MyPlanets+1;
  4170.          ActPProject:=ProjectPtr;
  4171.          for j:=1 to 42 do if ActPProject^[j]>0 then Buildings:=Buildings+1;
  4172.       end;
  4173.    end;
  4174.    if MyPlanets>0 then begin
  4175.       MAKEBORDER(MyScreen[1]^,30,250,480,360,12,6,1);
  4176.       Buildings:=Buildings div MyPlanets +1;
  4177.       s:='System: '+Save.SystemName[SysID];
  4178.       WRITE(256,260,SystemFlags[1,SysID] and FLAG_CIV_MASK,0+16,MyScreen[1]^,4,s);
  4179.       s:='Bevölkerung: '+intstr(SysPop)+' Millionen';
  4180.       WRITE(256,290,ThePlayerFlag,0+16,MyScreen[1]^,4,s);
  4181.       s:='Planeten: '+intstr(SystemHeader[SysID].Planets)+', davon '+intstr(MyPlanets)
  4182.         +' '+GETCIVADJ(GETCIVVAR(ThePlayerFlag));
  4183.       WRITE(256,310,ThePlayerFlag,0+16,MyScreen[1]^,4,s);
  4184.       if Buildings<3 then s:='praktisch nicht entwickelt'
  4185.       else if Buildings<5 then s:='geringe Entwicklungsstufe'
  4186.       else if Buildings<10 then s:='mäßig hoch entwickelt'
  4187.       else if Buildings<18 then s:='hoch entwickelt'
  4188.       else if Buildings>=34 then s:='höchste Entwicklungsstufe';
  4189.       WRITE(256,330,ThePlayerFlag,0+16,MyScreen[1]^,4,s);
  4190.    end;
  4191. end;
  4192.  
  4193.  
  4194.  
  4195. procedure VERHANDLUNG(CivFlag,Mode :byte);
  4196.  
  4197. type TextArr4=array [1..4] of str;
  4198.  
  4199. var CivStr,s,s2                 :string[55];
  4200. var XSystem,XTech,CivVar,i      :byte;
  4201. var XCosts                      :long;
  4202. var TArr4                       :TextArr4;
  4203.  
  4204.  
  4205. procedure INIT(Mode :byte);
  4206.  
  4207. begin
  4208.    MAKEBORDER(MyScreen[1]^,30,80,480,230,12,6,0);
  4209.    WRITE(256,90,CivFlag,0+16,MyScreen[1]^,4,CivStr);
  4210.    if Mode=1 then begin
  4211.       DrawImage(^MyScreen[1]^.RastPort,^GadImg1,60,200);
  4212.       DrawImage(^MyScreen[1]^.RastPort,^GadImg1,330,200);
  4213.       WRITE(118,202,0,16,MyScreen[1]^,4,'Annehmen');
  4214.       WRITE(388,202,0,16,MyScreen[1]^,4,'Ablehnen');
  4215.    end;
  4216. end;
  4217.  
  4218.  
  4219.  
  4220. begin
  4221.    CivVar:=GETCIVVAR(CivFlag);
  4222.    if (Save.WorldFlag=WFLAG_CEBORC) and (CivFlag=FLAG_OTHER) then exit;
  4223.    if CivFlag=FLAG_MAQUES then exit;
  4224.    if CivVar=0 then exit;
  4225.    if (Mode in [MODE_OFFENSIV,MODE_DEFENSIV])
  4226.    and (Save.CivPlayer[CivVar]<>0) then begin
  4227.       Save.WarState[CivVar,ActPlayer]:=LEVEL_WAR;
  4228.       Save.WarState[ActPlayer,CivVar]:=LEVEL_WAR;
  4229.       exit;
  4230.    end;
  4231.    case CivFlag of
  4232.       FLAG_TERRA:  CivStr:='Der Vertreter des Föderationsrates'
  4233.       FLAG_KLEGAN: CivStr:='Der Khalessor des Klingonischen Reiches';
  4234.       FLAG_REMALO: CivStr:='Der Deqaresto des Romulanischen Imperiums';
  4235.       FLAG_CARDAC: CivStr:='Der Legat des kardassianischen Zentralkommandos';
  4236.       FLAG_FERAGI: CivStr:='Der Gesandte der Ferengiallianz';
  4237.       FLAG_BAROJA: CivStr:='Der Vertreter des Bajoranischen Hohen Rates';
  4238.       FLAG_VOLKAN: CivStr:='Der Botschafter der vulkanischen Regierung';
  4239.       FLAG_OTHER:  case Save.WorldFlag of
  4240.                       WFLAG_DCON:   CivStr:='Der Vertreter des Tkon-Imperiums';
  4241.                       WFLAG_JAHADR: CivStr:='Der Vertreter des Dominion';
  4242.                       otherwise CivStr:='Die Militärführung der Rebellen';
  4243.                    end;
  4244.       otherwise exit;
  4245.    end;
  4246.    XSystem:=0;
  4247.    for i:=1 to Save.SYSTEMS do if SystemFlags[1,i] and FLAG_CIV_MASK=ActPlayerFlag then XSystem:=i;
  4248.    XTech:=0;
  4249.    for i:=42 downto 1 do if (Save.TechCosts[CivVar,i]>0) and (Save.TechCosts[ActPlayer,i]<=0) then XTech:=i;
  4250.    XCosts:=abs(Year) * 46;
  4251.    if (CivVar=8) and (Save.WorldFlag=WFLAG_JAHADR) then begin
  4252.       if Save.WarState[ActPlayer,8]<>LEVEL_WAR then begin
  4253.          INIT(1);
  4254.          i:=2*(1+(Save.WarPower[8] div Save.WarPower[ActPlayer]));
  4255.          if Mode=MODE_FORCE then begin
  4256.             s:='verurteilt das Verhalten der '+GETCIVNAME(ActPlayer)+' und';
  4257.             WRITE(256,110,FLAG_OTHER,16,MyScreen[1]^,4,s);
  4258.             WRITE(256,130,FLAG_OTHER,16,MyScreen[1]^,4,'fordert als Bestrafung und für die Wieder-');
  4259.             WRITE(256,150,FLAG_OTHER,16,MyScreen[1]^,4,'herstellung des Status Quo die Zahlung einer');
  4260.          end else begin
  4261.             WRITE(256,110,FLAG_OTHER,16,MyScreen[1]^,4,'bedauert den Überfall auf Stellungen');
  4262.             WRITE(256,130,FLAG_OTHER,16,MyScreen[1]^,4,'der Jem´Hadar und fordert als Entschädigung und für');
  4263.             WRITE(256,150,FLAG_OTHER,16,MyScreen[1]^,4,'die Wiederherstellung des Friedens die Zahlung einer');
  4264.          end;
  4265.          if Save.JSteuer[ActPlayer]=0 then s:='jährlichen Abgabe von '+intstr(i)+'% an das Dominion.'
  4266.          else s:='erhöhten jährlichen Sicherheitsabgabe.';
  4267.          WRITE(256,170,FLAG_OTHER,16,MyScreen[1]^,4,s);
  4268.          repeat
  4269.             delay(RDELAY);
  4270.          until (LData^ and 64=0) and (IBase^.MouseY in [200..220]) and (IBase^.MouseX in [60..176,330..446]);
  4271.          SYSINFO(0,0);
  4272.          if IBase^.MouseX in [60..176] then begin
  4273.             KLICKGAD(60,200);
  4274.             RECT(MyScreen[1]^,0,30,80,480,230);
  4275.             if Save.JSteuer[ActPlayer] in [1..99] then Save.JSteuer[ActPlayer]:=Save.JSteuer[ActPlayer]+1
  4276.             else Save.JSteuer[ActPlayer]:=i;
  4277.             Save.WarState[8,ActPlayer]:=LEVEL_PEACE;
  4278.             Save.WarState[ActPlayer,8]:=LEVEL_PEACE;
  4279.             PEACEINFO(ActPlayer,8,ActPlayerFlag,FLAG_OTHER);
  4280.             exit;
  4281.          end;
  4282.          KLICKGAD(330,200);
  4283.          INIT(0);
  4284.          WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'erklärt den uneingeschränkten Krieg bis zur');
  4285.          WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'Kapitulation oder der vollständigen');
  4286.          s:='Ausrottung der '+GETCIVADJ(ActPlayer)+' Rasse.';
  4287.          WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,s);
  4288.          WAITLOOP(false);
  4289.          RECT(MyScreen[1]^,0,30,80,480,230);
  4290.          Save.JSteuer[ActPlayer]:=0;
  4291.          Save.WarState[CivVar,ActPlayer]:=LEVEL_WAR;
  4292.          Save.WarState[ActPlayer,CivVar]:=LEVEL_WAR;
  4293.          exit;
  4294.       end else if (Save.WarPower[8]*2>Save.WarPower[ActPlayer]) then begin
  4295.          if (Year mod 6=0) then begin
  4296.             INIT(1);
  4297.             WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'weist auf die militärische Überlegenheit seiner');
  4298.             WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'Einheiten hin und verlangt als Bedingung für einen');
  4299.             WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,'Frieden die Zahlung einer Sicherheitsabgabe');
  4300.             i:=2*(1+(Save.WarPower[8] div Save.WarPower[ActPlayer]));
  4301.             if i>53 then i:=53;
  4302.             s:='in Höhe von '+intstr(i)+'% jährlich';
  4303.             WRITE(256,170,CivFlag,0+16,MyScreen[1]^,4,s);
  4304.             repeat
  4305.                delay(RDELAY);
  4306.             until (LData^ and 64=0) and (IBase^.MouseY in [200..220]) and (IBase^.MouseX in [60..176,330..446]);
  4307.             if IBase^.MouseX in [60..176] then begin
  4308.                KLICKGAD(60,200);
  4309.                RECT(MyScreen[1]^,0,30,80,480,230);
  4310.                Save.JSteuer[ActPlayer]:=i;
  4311.                Save.WarState[8,ActPlayer]:=LEVEL_PEACE;
  4312.                Save.WarState[ActPlayer,8]:=LEVEL_PEACE;
  4313.                PEACEINFO(ActPlayer,8,ActPlayerFlag,FLAG_OTHER);
  4314.                exit;
  4315.             end;
  4316.             KLICKGAD(330,200);
  4317.             RECT(MyScreen[1]^,0,30,80,480,230);
  4318.             exit;
  4319.          end else if Mode=MODE_FORCE then begin
  4320.             INIT(0);
  4321.             WRITE(256,115,CivFlag,0+16,MyScreen[1]^,4,'ist nicht dazu bereit, Verhandlungen aufzunehmen.');
  4322.             WAITLOOP(false);
  4323.             RECT(MyScreen[1]^,0,30,80,480,230);
  4324.             exit;
  4325.          end;
  4326.       end else if Save.WarPower[8]*2>Save.WarPower[ActPlayer] then exit;
  4327.    end;
  4328.    if Mode=MODE_BELEIDIGUNG then begin
  4329.       INIT(0);
  4330.       WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'faßt die Ablehnung seines Angebotes als Beleidigung');
  4331.       WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'und als Schwere Verletzung der Ehre seines Volkes');
  4332.       WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,'auf und erklärt den Krieg');
  4333.       WAITLOOP(false);
  4334.       RECT(MyScreen[1]^,0,30,80,480,230);
  4335.       Save.WarState[CivVar,ActPlayer]:=LEVEL_WAR;
  4336.       Save.WarState[ActPlayer,CivVar]:=LEVEL_WAR;
  4337.       exit;
  4338.    end else if Mode in [MODE_OFFENSIV,MODE_MONEY,MODE_FORCE] then begin
  4339.       if Save.WarState[CivVar,ActPlayer]<>LEVEL_WAR then begin
  4340.          INIT(1);
  4341.          if Mode<>MODE_MONEY then Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-50;
  4342.          s2:='verurteilt die '+GETCIVADJ(ActPlayer)+' Aggression auf das';
  4343.          TArr4:=TextArr4(s2,'schärfste und fordert für die Wiederherstellung',
  4344.                          '','');
  4345.          if Mode=MODE_MONEY then begin
  4346.             s:='gabe der Gewinne in Höhe von '+intstr(XCosts)+', die den';
  4347.             s2:='Ferengis durch das unfaire '+GETCIVADJ(ActPlayer);
  4348.             TArr4:=TextArr4('verlangt für den Erhalt des Friedens die Heraus-',
  4349.                             s,s2,
  4350.                             'Geschäftsgebaren entgangen sind!');
  4351.          end else if (Save.WarPower[ActPlayer]<Save.WarPower[CivVar]*3) and (XSystem>0) then begin
  4352.             TArr4[3]:='des Friedens die bedingungslose Übergabe des';
  4353.             s:='Systems '+Save.SystemName[XSystem]+'.';
  4354.             TArr4[4]:=^s;
  4355.             SYSINFO(XSystem,ActPlayerFlag);
  4356.          end else if (Save.WarPower[ActPlayer]<Save.WarPower[CivVar]*4) and (XTech>0) then begin
  4357.             s:=' '+Technology[XTech]+'.';
  4358.             if XTech in [12,13,15,18,20,23,24,28,30,33,36] then s:='den'+s
  4359.             else if XTech in [3,17,21,25,31] then s:='das'+s else s:='die'+s;
  4360.             TArr4[3]:='des Friedens die Übergabe von Informationen über';
  4361.             TArr4[4]:=^s;
  4362.          end else begin
  4363.             s:=intstr(XCosts);
  4364.             TArr4[3]:='des Friedens Reparationszahlungen in Höhe von';
  4365.             TArr4[4]:=^s;
  4366.          end;
  4367.          for i:=1 to 4 do WRITE(256,i*20+90,CivFlag,16,MyScreen[1]^,4,TArr4[i]);
  4368.          repeat
  4369.             delay(RDELAY);
  4370.          until (LData^ and 64=0) and (IBase^.MouseY in [200..220]) and (IBase^.MouseX in [60..176,330..446]);
  4371.          SYSINFO(0,0);
  4372.          if IBase^.MouseX in [60..176] then begin
  4373.             KLICKGAD(60,200);
  4374.             RECT(MyScreen[1]^,0,30,80,480,230);
  4375.             if (Save.WarPower[ActPlayer]<Save.WarPower[CivVar]*2) and (XSystem>0) then SYSTEMTOENEMY(XSystem,CivFlag,ActPlayerFlag)
  4376.             else if (Save.WarPower[ActPlayer]<Save.WarPower[CivVar]*3) and (XTech>0) then Save.TechCosts[XTech,CivVar]:=0
  4377.             else BEGIN
  4378.                Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]+XCosts;
  4379.                Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-XCosts;
  4380.             end;
  4381.             Save.WarState[CivVar,ActPlayer]:=LEVEL_PEACE;
  4382.             Save.WarState[ActPlayer,CivVar]:=LEVEL_PEACE;
  4383.             PEACEINFO(ActPlayer,CivVar,ActPlayerFlag,CivFlag);
  4384.             exit;
  4385.          end;
  4386.          KLICKGAD(330,200);
  4387.          INIT(0);
  4388.          WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'teilt den Abbruch aller Beziehungen');
  4389.          WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'und die Ausrufung des Krieges gegen');
  4390.          s:='die '+GETCIVNAME(ActPlayer)+' mit.';
  4391.          WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,s);
  4392.          WAITLOOP(false);
  4393.          RECT(MyScreen[1]^,0,30,80,480,230);
  4394.          Save.WarState[CivVar,ActPlayer]:=LEVEL_WAR;
  4395.          Save.WarState[ActPlayer,CivVar]:=LEVEL_WAR;
  4396.          exit;
  4397.       end;
  4398.       if (Save.WarState[CivVar,ActPlayer]=LEVEL_WAR) and (Save.WarPower[CivVar]*2<Save.WarPower[ActPlayer])
  4399.       and ((Year mod 6=0) or (Mode=MODE_FORCE)) then begin
  4400.          INIT(1);
  4401.          WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'bietet den Abschluß eines');
  4402.          WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'Friedensvertrages an.');
  4403.          repeat
  4404.             delay(RDELAY);
  4405.          until (LData^ and 64=0) and (IBase^.MouseY in [200..220]) and (IBase^.MouseX in [60..176,330..446]);
  4406.          if IBase^.MouseX in [60..176] then begin
  4407.             KLICKGAD(60,200);
  4408.             RECT(MyScreen[1]^,0,30,80,480,250);
  4409.             Save.WarState[CivVar,ActPlayer]:=LEVEL_PEACE;
  4410.             Save.WarState[ActPlayer,CivVar]:=LEVEL_PEACE;
  4411.             PEACEINFO(ActPlayer,CivVar,ActPlayerFlag,CivFlag);
  4412.             exit;
  4413.          end;
  4414.          KLICKGAD(330,200);
  4415.          RECT(MyScreen[1]^,0,30,80,480,250);
  4416.       end else if Mode=MODE_FORCE then begin
  4417.          MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  4418.          s:='Die Forderungen der '+GETCIVNAME(ActPlayer);
  4419.          WRITE(256,140,CivFlag,16,MyScreen[1]^,4,s);
  4420.          WRITE(256,165,CivFlag,16,MyScreen[1]^,4,'wurden zurückgewiesen.');
  4421.          WAITLOOP(false);
  4422.          RECT(MyScreen[1]^,0,85,120,425,200);
  4423.          REFRESHDISPLAY;
  4424.       end;
  4425.    end else if Mode in [MODE_DEFENSIV,MODE_TERRITORIUM] then begin
  4426.       if random(3)=0 then exit;
  4427.       if XSystem<>0 then begin
  4428.          INIT(1);
  4429.          if Mode=MODE_TERRITORIUM then begin
  4430.             WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'verurteilt die Verletzung seines Hoheitsgebietes');
  4431.             WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'und verlangt als Entschädigung für diese Aggression');
  4432.             WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,'die bedingungslose Übergabe des');
  4433.          end else begin
  4434.             WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'weist auf die militärische Überlegenheit seiner');
  4435.             WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'Zivilisation hin und verlangt als Vorbedingung');
  4436.             WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,'für einen Friedensvertrag die Übergabe des');
  4437.          end;
  4438.          s:=GETCIVADJ(ActPlayer)+'n Systems '+Save.SystemName[XSystem]+'.';
  4439.          WRITE(256,170,CivFlag,0+16,MyScreen[1]^,4,s);
  4440.          SYSINFO(XSystem,ActPlayerFlag);
  4441.          repeat
  4442.             delay(RDELAY);
  4443.          until (LData^ and 64=0) and (IBase^.MouseY in [200..220]) and (IBase^.MouseX in [60..176,330..446]);
  4444.          SYSINFO(0,0);
  4445.          if IBase^.MouseX in [60..176] then begin
  4446.             KLICKGAD(60,200);
  4447.             RECT(MyScreen[1]^,0,30,80,480,230);
  4448.             SYSTEMTOENEMY(XSystem,CivFlag,ActPlayerFlag);
  4449.             Save.WarState[CivVar,ActPlayer]:=LEVEL_PEACE;
  4450.             Save.WarState[ActPlayer,CivVar]:=LEVEL_PEACE;
  4451.             if random(100)<25 then XSystem:=0 else begin
  4452.                PEACEINFO(ActPlayer,CivVar,ActPlayerFlag,CivFlag);
  4453.                exit;
  4454.             end;
  4455.          end else begin
  4456.             KLICKGAD(330,200);
  4457.             RECT(MyScreen[1]^,0,30,80,480,230);
  4458.             if Save.WarState[CivVar,ActPlayer]=LEVEL_WAR then exit;
  4459.          end;
  4460.          INIT(0);
  4461.          if Mode=MODE_TERRITORIUM then begin
  4462.             WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'kann das illegale Eindringen auf sein Hoheits-');
  4463.             WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'gebiet nicht ungestraft hinnehmen. Er erklärt hiermit');
  4464.             s:='den Krieg gegen die '+GETCIVNAME(ActPlayer)+'!';
  4465.             WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,s);
  4466.          end else begin
  4467.             WRITE(256,110,CivFlag,0+16,MyScreen[1]^,4,'erteilt dem Wunsch nach Friedensverhandlungen');
  4468.             WRITE(256,130,CivFlag,0+16,MyScreen[1]^,4,'eine Absage und bricht sämtliche Beziehungen');
  4469.             s:='zur '+GETCIVADJ(ActPlayer)+'n Zivilisation ab.';
  4470.             WRITE(256,150,CivFlag,0+16,MyScreen[1]^,4,s);
  4471.          end;
  4472.          WAITLOOP(false);
  4473.          RECT(MyScreen[1]^,0,30,80,480,230);
  4474.          Save.WarState[CivVar,ActPlayer]:=LEVEL_WAR;
  4475.          Save.WarState[ActPlayer,CivVar]:=LEVEL_WAR;
  4476.       end;
  4477.    end;
  4478. end;
  4479.  
  4480.  
  4481.  
  4482. procedure GOTOPEACE(CivVar1,CivVar2 :byte);
  4483.  
  4484. begin
  4485.    Save.WarState[CivVar1,CivVar2]:=LEVEL_PEACE;
  4486.    Save.WarState[CivVar2,CivVar1]:=LEVEL_PEACE;
  4487.    if (Save.WarState[CivVar1,ActPlayer]=LEVEL_UNKNOWN) and (Save.WarState[CivVar2,ActPlayer]=LEVEL_UNKNOWN) then exit;
  4488.    if Save.WarState[CivVar1,ActPlayer]=LEVEL_ALLIANZ then begin
  4489.       Save.WarState[CivVar1,ActPlayer]:=LEVEL_PEACE;
  4490.       Save.WarState[ActPlayer,CivVar1]:=LEVEL_PEACE;
  4491.    end;
  4492.    if Save.WarState[CivVar2,ActPlayer]=LEVEL_ALLIANZ then begin
  4493.       Save.WarState[CivVar2,ActPlayer]:=LEVEL_PEACE;
  4494.       Save.WarState[ActPlayer,CivVar2]:=LEVEL_PEACE;
  4495.    end;
  4496.    PEACEINFO(CivVar1,CivVar2,GETCIVFLAG(CivVar1),GETCIVFLAG(CivVar2));
  4497. end;
  4498.  
  4499.  
  4500.  
  4501. procedure AUTOVERHANDLUNG(CivFlag1,CivFlag2,ActSys,Mode :byte);
  4502.  
  4503. var CivVar1,CivVar2,i,XSystem   :byte;
  4504.  
  4505. begin
  4506.    if (Save.WorldFlag=WFLAG_CEBORC) and ((CivFlag1=FLAG_OTHER) or (CivFlag2=FLAG_OTHER)) then exit;
  4507.    CivVar1:=GETCIVVAR(CivFlag1);
  4508.    CivVar2:=GETCIVVAR(CivFlag2);
  4509.    if (CivVar1 in [0,9]) or (CivVar2 in [0,9]) then exit;
  4510.    if (CivVar1=ActPlayer) or (CivVar2=ActPlayer) then INFORMUSER;
  4511.    if not Save.PlayMySelf and
  4512.    ((Save.CivPlayer[CivVar1]<>0) or (Save.CivPlayer[CivVar2]<>0)) then begin
  4513.       if (Mode in [MODE_TERRITORIUM,MODE_BELEIDIGUNG]) then begin
  4514.          if (CivFlag1=ActPlayerFlag) or (CivFlag2=ActPlayerFlag) then begin
  4515.             VERHANDLUNG(CivFlag1,Mode);
  4516.             REFRESHDISPLAY;
  4517.             exit;
  4518.          end;
  4519.       end else begin
  4520.          if CivFlag1=ActPlayerFlag then begin
  4521.             VERHANDLUNG(CivFlag2,MODE_OFFENSIV);
  4522.             REFRESHDISPLAY;
  4523.             exit;
  4524.          end else if CivFlag2=ActPlayerFlag then begin
  4525.             VERHANDLUNG(CivFlag1,MODE_DEFENSIV);
  4526.             REFRESHDISPLAY;
  4527.             exit;
  4528.          end;
  4529.       end;
  4530.       exit;
  4531.    end;
  4532.    if Year mod 4<>0 then exit;
  4533.    if (CivVar1=8) and (Save.WorldFlag=WFLAG_JAHADR)
  4534.    and (Save.WarPower[8]>Save.WarPower[CivVar2]*2) then begin
  4535.       if Save.JSteuer[CivVar2] in [1..99] then Save.JSteuer[CivVar2]:=Save.JSteuer[CivVar2]+1
  4536.       else begin
  4537.          Save.JSteuer[CivVar2]:=2*(1+(Save.WarPower[8] div succ(Save.WarPower[CivVar2])));
  4538.          if Save.JSteuer[CivVar2]>53 then Save.JSteuer[CivVar2]:=53;
  4539.       end;
  4540.       GOTOPEACE(CivVar1,CivVar2);
  4541.       exit;
  4542.    end else begin
  4543.       Save.JSteuer[CivVar2]:=0;
  4544.       exit;
  4545.    end;
  4546.    if Save.WarPower[CivVar1]>Save.WarPower[CivVar2]*5 then exit;
  4547.    if Save.WarPower[CivVar1]>Save.WarPower[CivVar2]*3 then begin
  4548.       if TAKETECH(CivFlag1,CivFlag2) then begin
  4549.          GOTOPEACE(CivVar1,CivVar2);
  4550.          exit;
  4551.       end;
  4552.    end;
  4553.    if Save.WarPower[CivVar1]>Save.WarPower[CivVar2]*2 then begin
  4554.       Save.Staatstopf[CivVar1]:=Save.Staatstopf[CivVar1]+abs(Year*10);
  4555.       Save.Staatstopf[CivVar2]:=Save.Staatstopf[CivVar2]-abs(Year*10);
  4556.       GOTOPEACE(CivVar1,CivVar2);
  4557.    end;
  4558. end;
  4559.  
  4560.  
  4561.  
  4562. procedure PLANETINFO(ActSys :byte);
  4563.  
  4564. const MAXPROJECT=30;
  4565.  
  4566. type SArr6=array [1..6] of str;
  4567.  
  4568. var SA6                 :SArr6;
  4569. var c,x,y,l             :long;
  4570. var i,j                 :integer;
  4571. var PlanetHeader        :^r_PlanetHeader;
  4572.  
  4573. begin
  4574.    PlanetHeader:=ObjPtr;
  4575.    with PlanetHeader^ do if (PFlags and FLAG_CIV_MASK<>ActPlayerFlag) then begin
  4576.       MAKEBORDER(MyScreen[1]^,81,81,428,278,12,6,0);
  4577.       MAKEBORDER(MyScreen[1]^,90,90,161,161,12,6,1);
  4578.       j:=12;
  4579.       if PFlags>0 then j:=PFlags;
  4580.       s:=realstr(Size/10,2)+' facher Erdradius';
  4581.       WRITE(170,114,j,0,MyScreen[1]^,4,s);
  4582.       s:='Klasse ';
  4583.       case Class of
  4584.          CLASS_DESERT    : s:=s+'D';
  4585.          CLASS_HALFEARTH : s:=s+'H';
  4586.          CLASS_EARTH     : s:=s+'M';
  4587.          CLASS_SATURN    : s:=s+'S';
  4588.          CLASS_GAS       : s:=s+'G';
  4589.          CLASS_ICE       : s:=s+'I';
  4590.          CLASS_PHANTOM   : s:=s+'P';
  4591.          CLASS_STONES    : s:=s+'T';
  4592.          CLASS_WATER     : s:=s+'W';
  4593.       end;
  4594.       s:=s+'-Planet';
  4595.       WRITE(170,134,j,0,MyScreen[1]^,4,s);
  4596.       i:=round((abs(PosX)+abs(PosY))/3.4);
  4597.       l:=(13-i)*(13-i)*(13-i) div 3 -270;
  4598.       WRITE(170,94,j,0,MyScreen[1]^,4,PName);
  4599.       if Class in [CLASS_SATURN,CLASS_GAS] then s:='- Temperaturen im Bereich '
  4600.       else s:='- Anteil Wasser der Oberfläche: ';
  4601.       case Class of
  4602.          CLASS_DESERT:    begin
  4603.                              s:=s+intstr(Water div Size)+'%';
  4604.                              SA6:=SArr6('- wüstenartiger Planet','- Lebensformen möglich',
  4605.                                         '- Rohstoffe vorhanden','- ca. 60% Besiedelung möglich',
  4606.                                         '- sehr geringe Wasservorkommen',s);
  4607.                              l:=5;
  4608.                           end;
  4609.          CLASS_HALFEARTH: begin
  4610.                              s:=s+intstr(Water div Size)+'%';
  4611.                              SA6:=Sarr6('- erdähnlicher Planet','- gute Bedingungen für Lebensformen',
  4612.                                         '- Rohstoffe vorhanden','- ca. 80% Besiedelung möglich',
  4613.                                         '- Wasservorkommen, Athmosphäre, Wetter',s);
  4614.                              l:=4;
  4615.                           end;
  4616.          CLASS_EARTH:     begin
  4617.                              s:=s+intstr(Water div Size)+'%';
  4618.                              SA6:=SArr6('- erdartiger Planet','- sehr gute Bedingungen für Lebensformen',
  4619.                                         '- Rohstoffe vorhanden','- ca. 95% Besiedelung möglich',
  4620.                                         '- große Wasservorkommen, Athmosphäre, Wetter',s);
  4621.                              l:=6;
  4622.                           end;
  4623.          CLASS_SATURN:    begin
  4624.                              s:=s+intstr(l)+' .. '+intstr(l+(12-i)*10)+ '°C';
  4625.                              SA6:=SArr6('- Planet der Saturnklasse','- Lebensformen nicht möglich',
  4626.                                         '- keine Rohstoffe','- Besiedelung nicht möglich',
  4627.                                         '- Athmosphäre, Gasplanet',s);
  4628.                              l:=3;
  4629.                           end;
  4630.          CLASS_GAS:       begin
  4631.                              s:=s+intstr(l)+' .. '+intstr(l+(12-i)*10)+ '°C';
  4632.                              SA6:=SArr6('- sonnenähnlicher Gasplanet','- Lebensformen nicht möglich',
  4633.                                         '- keine Rohstoffe','- Besiedelung nicht möglich',
  4634.                                         '- Athmosphäre mit starken Turbulenzen',s);
  4635.                              l:=1;
  4636.                           end;
  4637.          CLASS_ICE:       begin
  4638.                              s:=s+intstr(Water div Size)+'%';
  4639.                              SA6:=SArr6('- Eisplanet','- Lebensformen möglich',
  4640.                                         '- Rohstoffe','- ca. 60% Besiedelung möglich',
  4641.                                         '- große Wasservorkommen, Athmosphäre, Wetter',s);
  4642.                              l:=8;
  4643.                           end;
  4644.          CLASS_PHANTOM:   begin
  4645.                              SA6:=SArr6('- Phantomplanet','- keine Informationen',
  4646.                                         '','','','');
  4647.                              l:=7;
  4648.                           end;
  4649.          CLASS_STONES:    begin
  4650.                              s:=s+intstr(Water div Size)+'%';
  4651.                              SA6:=SArr6('- frühes Entwicklungsstadium','- Lebensformen nicht möglich',
  4652.                                         '- wenig Rohstoffe','- ca. 75% Besiedelung möglich',
  4653.                                         '- Athmosphäre, Wetter, starke Erdbeben',s);
  4654.                              l:=0;
  4655.                           end;
  4656.          CLASS_WATER:     begin
  4657.                              s:=s+intstr(Water div Size)+'%';
  4658.                              SA6:=SArr6('- Wasserplanet','- Lebensformen möglich',
  4659.                                         '- Rohstoffe','- ca. 60% Besiedelung möglich',
  4660.                                         '- über 90% Wasser, Athmosphäre, Wetter',s);
  4661.                              l:=2;
  4662.                           end;
  4663.          otherwise;
  4664.       end;
  4665.       for i:=1 to 6 do WRITE(90,i*17+151,12,0,MyScreen[1]^,3,SA6[i]);
  4666.       x:=0; y:=0;
  4667.       repeat
  4668.          delay(RDELAY);
  4669.          if (x<32) and (y<32) then begin
  4670.             BltBitMapRastPort(^ImgBitMap7,l*32+x,y,^MyScreen[1]^.RastPort,x*2+93,y*2+93,1,1,192);
  4671.             BltBitMapRastPort(^ImgBitMap7,l*32+x,y,^MyScreen[1]^.RastPort,x*2+94,y*2+93,1,1,192);
  4672.             BltBitMapRastPort(^ImgBitMap7,l*32+x,y,^MyScreen[1]^.RastPort,x*2+93,y*2+94,1,1,192);
  4673.             BltBitMapRastPort(^ImgBitMap7,l*32+x,y,^MyScreen[1]^.RastPort,x*2+94,y*2+94,1,1,192);
  4674.             x:=x+1;
  4675.             if x>31 then begin
  4676.                x:=1; y:=y+1;
  4677.             end;
  4678.          end;
  4679.       until (LData^ and 64=0) or (RData^ and 1024=0);
  4680.       PLAYSOUND(1,300);
  4681.       RECT(MyScreen[1]^,0,80,80,430,280);
  4682.       REFRESHDISPLAY;
  4683.    end else HANDLEKNOWNPLANET(ActSys,0,PlanetHeader);
  4684. end;
  4685.  
  4686.  
  4687.  
  4688. procedure AUTOSHIPTRAVEL(ActSys,Mode :byte; ShipPtr :ptr);
  4689. forward;
  4690.  
  4691.  
  4692.  
  4693. procedure  CLOCK;
  4694.  
  4695. var LastSec,Stunde,Minute,Rest  :long;
  4696.  
  4697. begin
  4698.    with IBase^ do begin;
  4699.       LastSec:=IBase^.Seconds;
  4700.       if LastSec mod 5<>0 then exit;
  4701.       Stunde:=LastSec div 3600;        Rest:=Stunde*3600;
  4702.       Minute:=(LastSec-Rest) div 60;   Rest:=Rest+Minute*60;
  4703.       Stunde:=Stunde-(Stunde div 24 * 24);
  4704.       s:='';
  4705.       if Stunde<10 then s:=s+'0';      s:=s+intstr(Stunde)+':';
  4706.       if Minute<10 then s:=s+'0';      s:=s+intstr(Minute);
  4707.       if (Stunde in [0..8,22..23]) and not DoClock then begin
  4708.          DoClock:=true;
  4709.          MAKEBORDER(MyScreen[1]^,537,350,614,372,29,12,0);
  4710.       end;
  4711.       if DoClock then WRITE(541,354,8,1,MyScreen[1]^,2,s);
  4712.    end;
  4713. end;
  4714.  
  4715.  
  4716.  
  4717. procedure CEBORCATTACK(ActPlayerFlag :byte);
  4718.  
  4719. var i,j         :byte;
  4720. var l           :long;
  4721. var MyShipPtr   :^r_ShipHeader;
  4722.  
  4723. begin
  4724.    if not Save.WorldFlag in [0,WFLAG_CEBORC] then exit;
  4725.    Save.WorldFlag:=WFLAG_CEBORC;
  4726.    if ActPlayerFlag<>0 then begin
  4727.       l:=0;
  4728.       for i:=1 to Save.SYSTEMS do
  4729.        if SystemFlags[1,i] and FLAG_CIV_MASK=ActPlayerFlag then l:=1;
  4730.       if l=0 then exit;
  4731.    end;
  4732.    repeat
  4733.       j:=random(Save.SYSTEMS)+1;
  4734.    until (ActPlayerFlag=0)
  4735.    or (SystemFlags[1,j] and FLAG_CIV_MASK=ActPlayerFlag);
  4736.    for i:=1 to pred(MAXCIVS) do Save.WarState[8,i]:=LEVEL_COLDWAR;
  4737.    for i:=1 to (random(6)+3) do begin
  4738.       Save.Bevölkerung[8]:=Save.Bevölkerung[8]+1;
  4739.       l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  4740.       MyShipPtr:=ptr(l);
  4741.       MyShipPtr^:=r_ShipHeader(0,27,FLAG_OTHER,0,100,1,0,random(20)-40,random(20)-40,
  4742.                                ShipData[27].MaxShield,WEAPON_PTORPEDO,1,
  4743.                                ShipData[27].MaxMove,0,0,0,NIL,NIL,NIL);
  4744.       LINKSHIP(MyShipPtr,^SystemHeader[j].FirstShip,0);
  4745.    end;
  4746. end;
  4747.  
  4748.  
  4749.  
  4750. function CREATEMAQUESSHIP(SysID,ShipID :byte):boolean;
  4751.  
  4752. var ActShipPtr  :^r_ShipHeader;
  4753. var i           :byte;
  4754. var l           :long;
  4755.  
  4756. begin
  4757.    CREATEMAQUESSHIP:=false;
  4758.    if (Year>=2000) and (random(4)>0) then exit;
  4759.    CREATEMAQUESSHIP:=true;
  4760.    l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  4761.    if l=0 then exit;
  4762.    ActShipPtr:=ptr(l);
  4763.    if ShipID>8 then ShipID:=ShipID-1;
  4764.    ActShipPtr^:=r_ShipHeader(0,ShipID,FLAG_MAQUES,0,0,0,0,0,0,
  4765.                              ShipData[ShipID].MaxShield,1,1,
  4766.                              -10,0,0,0,NIL,NIL,NIL);
  4767.                             {Age,SType,Owner,Flags,ShieldBonus,Ladung,Fracht,PosX,PosY,
  4768.                              Shield,Weapon,Repair
  4769.                              Moving,Source,Target,Tactical,TargetShip,BeforeShip,NextShip}
  4770.    with ActShipPtr^ do begin
  4771.       Weapon:=WEAPON_GUN;
  4772.       if Save.TechCosts[ActPlayer,15]<=0 then Weapon:=WEAPON_LASER;
  4773.       if Save.TechCosts[ActPlayer,24]<=0 then Weapon:=WEAPON_PHASER;
  4774.       if Save.TechCosts[ActPlayer,32]<=0 then Weapon:=WEAPON_DISRUPTOR;
  4775.       if Save.TechCosts[ActPlayer,27]<=0 then Weapon:=WEAPON_PTORPEDO;
  4776.    end;
  4777.    LINKSHIP(ActShipPtr,^SystemHeader[SysID].FirstShip,0);
  4778.    for i:=1 to pred(MAXCIVS) do begin
  4779.       Save.WarState[9,i]:=LEVEL_WAR;     Save.WarState[i,9]:=LEVEL_WAR;
  4780.       Save.LastWarState[9,i]:=LEVEL_WAR; Save.LastWarState[i,9]:=LEVEL_WAR;
  4781.    end;
  4782.    Save.WarState[9,9]:=LEVEL_PEACE;
  4783. end;
  4784.  
  4785.  
  4786.  
  4787. procedure CREATECIVILWAR(CivVar :byte);
  4788.  
  4789. var i,j,CivFlag         :byte;
  4790. var MyPlanetHeader      :PlanetHeader;
  4791. var MyShipPtr           :ShipHeader;
  4792. var s                   :string;
  4793. var ModC,ModL           :long;
  4794.  
  4795. begin
  4796.    CivFlag:=GETCIVFLAG(CivVar);
  4797.    ModC:=0;
  4798.    if not Save.WorldFlag in [0,CivFlag] then exit;
  4799.    if Save.WorldFlag=0 then begin
  4800.       if Save.CivPlayer[CivVar]<>0 then begin
  4801.          ModC:=GETTHESOUND(2);
  4802.          ModL:=ModMemL[2];
  4803.          s:='Das Militär der '+GETCIVNAME(CivVar)+' putscht und spaltet';
  4804.          case CivFlag of
  4805.             FLAG_TERRA:  REQUEST('Teile der Sternenflotte putschen und spalten',
  4806.                                  'die Föderation in zwei Teile!',CivFlag,CivFlag);
  4807.             FLAG_KLEGAN: REQUEST('Das Haus der Duras putscht und',
  4808.                                  'spaltet das Reich in zwei Teile!',CivFlag,CivFlag);
  4809.             FLAG_REMALO: REQUEST('Die Talshiar putschen und spalten das',
  4810.                                  'Romulanische Imperium in zwei Teile!',CivFlag,CivFlag);
  4811.             FLAG_CARDAC: REQUEST('Der obsidianische Orden putscht und',
  4812.                                  'spaltet das Militär in zwei Teile!',CivFlag,CivFlag);
  4813.             FLAG_FERAGI: REQUEST('Das Militär putscht und spaltet die',
  4814.                                  'Ferengiallianz in zwei Teile!',CivFlag,CivFlag);
  4815.             otherwise REQUEST(s,'das Imperium in zwei Teile!',CivFlag,CivFlag);
  4816.          end;
  4817.       end;
  4818.       for i:=1 to pred(MAXCIVS) do begin
  4819.          Save.WarState[i,8]:=LEVEL_PEACE;
  4820.          Save.WarState[8,i]:=LEVEL_PEACE
  4821.       end;
  4822.       Save.WarState[CivVar,8]:=LEVEL_WAR;
  4823.       Save.WarState[8,CivVar]:=LEVEL_WAR;
  4824.       Save.GSteuer[8]:=0;
  4825.       Save.Staatstopf[8]:=-5000;
  4826.       for i:=1 to 42 do begin
  4827.          Save.TechCosts[8,i]:=Save.TechCosts[CivVar,i];
  4828.          Save.ProjectCosts[8,i]:=Save.ProjectCosts[CivVar,i];
  4829.       end;
  4830.    end;
  4831.    Save.WorldFlag:=CivFlag;
  4832.    Save.CivilWar:=CivVar;
  4833.    SETWORLDCOLORS;
  4834.    for i:=1 to Save.SYSTEMS do begin
  4835.       for j:=1 to SystemHeader[i].Planets do begin
  4836.          MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  4837.          with MyPlanetHeader^ do if (GETCIVVAR(PFlags)=CivVar) and (random(100)>=50) then begin
  4838.             PFlags:=FLAG_OTHER;
  4839.             Save.Bevölkerung[8]:=Save.Bevölkerung[8]+Population;
  4840.             if FirstShip.NextShip<>NIL then begin
  4841.                MyShipPtr:=FirstShip.NextShip;
  4842.                repeat
  4843.                   MyShipPtr^.Owner:=(PFlags and FLAG_CIV_MASK);
  4844.                   Save.WarPower[8]:=Save.WarPower[8]+round(ShipData[MyShipPtr^.SType].WeaponPower*(MyShipPtr^.Weapon/10+1));
  4845.                   MyShipPtr:=MyShipPtr^.NextShip;
  4846.                until MyShipPtr=NIL;
  4847.             end;
  4848.          end;
  4849.       end;
  4850.    end;
  4851.    if ModC<>0 then begin
  4852.       StopPlayer;
  4853.       FreeMem(ModC,ModL);
  4854.    end;
  4855.    if Save.WarPower[8]*3<Save.WarPower[CivVar]-Save.WarPower[8] then CREATECIVILWAR(CivVar);
  4856. end;
  4857.  
  4858.  
  4859.  
  4860. procedure JAHADRINVASION(ActPlayer :byte);
  4861.  
  4862. var ShipID,SysID        :byte;
  4863. var l                   :long;
  4864. var MyShipPtr           :ShipHeader;
  4865.  
  4866. begin
  4867.    if not Save.WorldFlag in [0,WFLAG_JAHADR] then exit;
  4868.    Save.WorldFlag:=WFLAG_JAHADR;
  4869.    Save.Bevölkerung[8]:=100;
  4870.    if Year>0 then Save.Staatstopf[8]:=Save.Staatstopf[8]+abs(Year)*120
  4871.    else Save.Staatstopf[8]:=200000;
  4872.    l:=0;
  4873.    ShipID:=0;
  4874.    for i:=24 downto 8 do if (Save.TechCosts[ActPlayer,ProjectNeedsTech[i]]<=0) then
  4875.     if (l<3) then begin
  4876.       l:=l+1;
  4877.       ShipID:=i;
  4878.    end;
  4879.    if ShipID<10 then ShipID:=10;
  4880.    l:=1000;
  4881.    for i:=1 to Save.SYSTEMS do if SystemX[i]+SystemY[i]<l then begin
  4882.       SysID:=i;
  4883.       l:=SystemX[i]+SystemY[i];
  4884.    end;
  4885.  
  4886.    for i:=1 to pred(MAXCIVS) do
  4887.     if Save.WarState[8,i] in [LEVEL_PEACE,LEVEL_UNKNOWN,LEVEL_DIED]
  4888.     then Save.WarState[8,i]:=LEVEL_COLDWAR;
  4889.    for i:=1 to (random(12)+3) do begin
  4890.       l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  4891.       MyShipPtr:=ptr(l);
  4892.       MyShipPtr^:=r_ShipHeader(0,ShipID,FLAG_OTHER,0,15,$F1,0,random(20)-40,random(20)-40,
  4893.                                ShipData[ShipID].MaxShield,WEAPON_PTORPEDO,1,
  4894.                                ShipData[ShipID].MaxMove,0,0,0,NIL,NIL,NIL);
  4895.       LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,0);
  4896.    end;
  4897. end;
  4898.  
  4899.  
  4900.  
  4901. procedure PUMPUPTHELEVEL;
  4902.  
  4903. var b   :boolean;
  4904. var i,j :byte;
  4905.  
  4906. begin
  4907.    b:=false;
  4908.    repeat
  4909.       case random(6) of
  4910.          0: if Save.WorldFlag in [0,WFLAG_CEBORC] then begin
  4911.                CEBORCATTACK(ActPlayerFlag);
  4912.                b:=true;
  4913.             end;
  4914.          1: if Save.WorldFlag in [0,WFLAG_JAHADR] then for i:=1 to MAXCIVS-2 do
  4915.             if (i<>ActPlayer) and not b and (Save.WarPower[i]>=Save.WarPower[ActPlayer])
  4916.             then begin
  4917.                CREATEJAHADR(i);
  4918.                b:=true;
  4919.             end;
  4920.          2: begin
  4921.                for i:=1 to MAXCIVS-2 do for j:=1 to MAXCIVS-2 do
  4922.                if (Save.WarState[i,j]<>LEVEL_DIED) and (Save.WarState[j,i]<>LEVEL_DIED) then begin
  4923.                   if (i<>ActPlayer) and (j<>ActPlayer)
  4924.                   and (Save.CivPlayer[i]=0) and (Save.CivPlayer[j]=0)
  4925.                   then begin
  4926.                      Save.WarState[i,j]:=LEVEL_PEACE;
  4927.                      Save.WarState[j,i]:=LEVEL_PEACE;
  4928.                      Save.Staatstopf[i]:=Save.Staatstopf[i]+5000;
  4929.                      Save.Staatstopf[j]:=Save.Staatstopf[j]+5000;
  4930.                   end else if (i<>j) then begin
  4931.                      Save.WarState[i,j]:=LEVEL_COLDWAR;
  4932.                      Save.WarState[j,i]:=LEVEL_COLDWAR;
  4933.                   end;
  4934.                end;
  4935.                b:=true;
  4936.             end;
  4937.          3: begin
  4938.                for i:=1 to 25 do repeat until CREATEMAQUESSHIP(i,random(5)+19);
  4939.                b:=true;
  4940.             end;
  4941.          4: if Save.WorldFlag in [0,ActPlayerFlag] then begin
  4942.                CREATECIVILWAR(ActPlayer);
  4943.                b:=true;
  4944.             end;
  4945.          5: if Save.WorldFlag in [0,WFLAG_JAHADR] then begin
  4946.                JAHADRINVASION(ActPlayer);
  4947.                b:=true;
  4948.             end;
  4949.       end;
  4950.    until b;
  4951.    REQUEST('Der Schwierigkeitsgrad des Spieles wurde erhöht.','Viel Vergnügen!',12,12);
  4952. end;
  4953.  
  4954.  
  4955.  
  4956. procedure STARDESASTER(ActSys :byte, ShipPtr :ptr);
  4957.  
  4958. type NameArr=array[0..25] of char;
  4959.  
  4960. var NArr                :NameArr;
  4961. var i,j,k               :byte;
  4962. var MyPlanetHeader      :^r_PlanetHeader;
  4963. var MyShipPtr           :^r_ShipHeader;
  4964. var ActPPRoject         :^ByteArr42;
  4965. var b                   :boolean;
  4966. var l                   :long;
  4967.  
  4968.  
  4969.  
  4970. procedure FUCKSYSTEM;
  4971.  
  4972. begin
  4973.    for i:=1 to SystemHeader[ActSys].Planets do begin
  4974.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(i)*sizeof(r_PlanetHeader));
  4975.       with MyPlanetHeader^ do if not (Class in [CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM]) then begin
  4976.          if ProjectPtr<>NIL then begin
  4977.             ActPProject:=Ptr(ProjectPtr);
  4978.             for j:=1 to 7 do if ActPProject^[j]>0 then Save.ProjectCosts[GETCIVVAR(PFlags),j]:=abs(Year)*j*10;
  4979.             for j:=8 to 42 do ActPProject^[j]:=0;
  4980.          end;
  4981.          Class:=CLASS_DESERT;
  4982.          Water:=Size*12;
  4983.          PFlags:=0;
  4984.          Ethno:=0;         Population:=0;
  4985.          Biosphäre:=0;
  4986.          Industrie:=0;     Infrastruktur:=0;
  4987.          XProjectCosts:=0; XProjectPayed:=0;
  4988.          ProjectID:=0;
  4989.       end;
  4990.       with MyPlanetHeader^ do if FirstShip.NextShip<>NIL then begin
  4991.          MyShipPtr:=FirstShip.NextShip;
  4992.          repeat
  4993.             MyShipPtr^.Owner:=0;
  4994.             MyShipPtr:=MyShipPtr^.NextShip;
  4995.          until MyShipPtr=NIL;
  4996.       end;
  4997.       if SystemHeader[ActSys].FirstShip.NextShip<>NIL then begin
  4998.          SystemHeader[ActSys].FirstShip.SType:=0;
  4999.          MyShipPtr:=SystemHeader[ActSys].FirstShip.NextShip;
  5000.          repeat
  5001.             MyShipPtr^.Owner:=0;
  5002.             MyShipPtr:=MyShipPtr^.NextShip;
  5003.          until MyShipPtr=NIL;
  5004.       end;
  5005.    end;
  5006.    DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  5007.    for i:=1 to 5 do begin
  5008.       SetRGB32(^MyScreen[1]^.ViewPort,0,$FF000000,$FF000000,$FF000000);
  5009.       PLAYSOUND(2,1200+random(250));
  5010.       delay(random(10)+1);
  5011.       SetRGB32(^MyScreen[1]^.ViewPort,0,0,0,0);
  5012.       delay(random(10)+1);
  5013.    end;
  5014.    delay(100);
  5015. end;
  5016.  
  5017.  
  5018. begin
  5019.    MyShipPtr:=ShipPtr;
  5020.    if Save.WorldFlag=WFLAG_FIELD then begin
  5021.       Save.SYSTEMS:=MAXSYSTEMS;
  5022.       Save.WorldFlag:=0;
  5023.       PLAYSOUND(3,420);
  5024.       MAKEBORDER(MyScreen[1]^,50,100,460,175,12,6,0);
  5025.       WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Störung im Raum-Zeit-Kontinuum!');
  5026.       WRITE(256,130,ActPlayerFlag,16,MyScreen[1]^,4,'Die Anomalie wurde beseitigt, alle');
  5027.       WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,'Planeten des Quadranten sind wieder frei.');
  5028.       WAITLOOP(false);
  5029.       RECT(MyScreen[1]^,0,50,100,460,175);
  5030.       REFRESHDISPLAY;
  5031.       exit;
  5032.    end;
  5033.    Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-500;
  5034.    if Save.WorldFlag<>0 then begin
  5035.       FUCKSYSTEM;
  5036.       exit;
  5037.    end;
  5038.    Save.GSteuer[8]:=0;
  5039.    case random(5) of
  5040.       0: FUCKSYSTEM;  { SONNENSYS ZERSTÖRT }
  5041.       1: begin        { NEUVERTEILUNG DER KRÄFTE }
  5042.             PLAYSOUND(3,420);
  5043.             Year:=Year-random(250)+75;
  5044.             MAKEBORDER(MyScreen[1]^,50,100,460,175,12,6,0);
  5045.             WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Riß im Raum-Zeit-Kontinuum!');
  5046.             WRITE(256,130,ActPlayerFlag,16,MyScreen[1]^,4,'Der Spieler wurde dadurch in ein');
  5047.             WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,'Parallel-Universum versetzt!');
  5048.             for i:=1 to Save.SYSTEMS do begin
  5049.                repeat
  5050.                   SystemX[i]:=5+random(250)+random(210);
  5051.                   SystemY[i]:=5+random(240)+random(240);
  5052.                   b:=true;
  5053.                   for j:=1 to pred(i) do if SystemY[i] in [SystemY[j]-10..SystemY[j]+10] then b:=false;
  5054.                until b;
  5055.             end;
  5056.             for i:=1 to 7 do for j:=1 to 7 do Save.WarState[i,j]:=LEVEL_COLDWAR;
  5057.             for j:=1 to 7 do begin
  5058.                for i:=1 to 25 do Save.TechCosts[j,i]:=0;
  5059.                for i:=26 to 42 do Save.TechCosts[j,i]:=i*2500;
  5060.                for i:=2 to 7 do Save.ProjectCosts[j,i]:=i*100000;
  5061.                Save.ProjectCosts[j,39]:=40000;
  5062.                Save.ActTech[j]:=0;
  5063.             end;
  5064.             for i:=1 to Save.SYSTEMS do begin
  5065.                SystemHeader[i].FirstShip.SType:=0;
  5066.                SystemHeader[i].vNS:=0;
  5067.                for j:=1 to SystemHeader[i].Planets do begin
  5068.                   MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  5069.                   with MyPlanetHeader^ do if PFlags<>0 then begin
  5070.                      case random(7) of
  5071.                         0: PFlags:=FLAG_TERRA;
  5072.                         1: PFlags:=FLAG_KLEGAN;
  5073.                         2: PFlags:=FLAG_REMALO;
  5074.                         3: PFlags:=FLAG_CARDAC;
  5075.                         4: PFlags:=FLAG_BAROJA;
  5076.                         5: PFlags:=FLAG_VOLKAN;
  5077.                         6: PFlags:=FLAG_FERAGI;
  5078.                      end;
  5079.                      Ethno:=(PFlags and FLAG_CIV_MASK);
  5080.                      Biosphäre:=Biosphäre-random(20);
  5081.                      Infrastruktur:=Biosphäre-random(20);
  5082.                      Industrie:=Industrie-random(20);
  5083.                      if ProjectPtr<>NIL then begin
  5084.                         ActPProject:=Ptr(ProjectPtr);
  5085.                         ActPProject^[2]:=0;
  5086.                         ActPPRoject^[39]:=0;
  5087.                         for k:=1 to 42 do if ProjectNeedsTech[k]>0 then ActPProject^[k]:=0;
  5088.                      end;
  5089.                      ProjectID:=-3;
  5090.                      Population:=round(Population*0.7);
  5091.                      if FirstShip.NextShip<>NIL then begin
  5092.                         MyShipPtr:=FirstShip.NextShip;
  5093.                         repeat
  5094.                            MyShipPtr^.Owner:=(PFlags and FLAG_CIV_MASK);
  5095.                            MyShipPtr:=MyShipPtr^.NextShip;
  5096.                         until MyShipPtr=NIL;
  5097.                      end;
  5098.                   end;
  5099.                end;
  5100.             end;
  5101.             WAITLOOP(false);
  5102.             RECT(MyScreen[1]^,0,50,100,460,175);
  5103.          end;
  5104.       2: begin   { CEBORCS }
  5105.             PLAYSOUND(3,420);
  5106.             MAKEBORDER(MyScreen[1]^,50,100,460,175,12,6,0);
  5107.             WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Riß im Raum-Zeit-Kontinuum!');
  5108.             WRITE(256,130,ActPlayerFlag,16,MyScreen[1]^,4,'Das Universum hatte zeitweilig Kontakt');
  5109.             WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,'zu einem Parallel-Universum!');
  5110.             CEBORCATTACK(0);
  5111.             WAITLOOP(false);
  5112.             RECT(MyScreen[1]^,0,50,100,460,175);
  5113.          end;
  5114.       3: begin   { DCON-IMPERIUM }
  5115.             PLAYSOUND(3,420);
  5116.             MAKEBORDER(MyScreen[1]^,50,100,460,175,12,6,0);
  5117.             WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Riß im Raum-Zeit-Kontinuum!');
  5118.             WRITE(256,130,ActPlayerFlag,16,MyScreen[1]^,4,'Das Sonnensystem wurde in eine');
  5119.             WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,'andere Zeit versetzt!');
  5120.             while Year>-40000 do Year:=Year-random(89)*random(89);
  5121.             Save.Bevölkerung[8]:=100;
  5122.             Save.WorldFlag:=WFLAG_DCON;
  5123.             for i:=1 to pred(MAXCIVS) do begin
  5124.                Save.WarState[8,i]:=LEVEL_PEACE;
  5125.                Save.WarState[i,8]:=LEVEL_PEACE;
  5126.             end;
  5127.             NArr:=NameArr('a','e','i','o','u',
  5128.                           'b','c','d','f','g','h','j','k','l','m','n','p',
  5129.                           'q','r','s','t','v','w','x','y','z');
  5130.             for i:=1 to MAXSYSTEMS do if i<>ActSys then begin
  5131.                Save.SystemName[i]:='Tk'+NArr[random(6)]+NArr[random(20)+6]
  5132.                                   +NArr[random(6)]+NArr[random(20)+6];
  5133.                SystemHeader[i].FirstShip.SType:=0;
  5134.                SystemHeader[i].FirstShip.Owner:=0;
  5135.                if SystemHeader[i].FirstShip.NextShip<>NIL then begin
  5136.                   MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  5137.                   repeat
  5138.                      MyShipPtr^.Owner:=FLAG_OTHER;
  5139.                      MyShipPtr:=MyShipPtr^.NextShip;
  5140.                   until MyShipPtr=NIL;
  5141.                end;
  5142.                for j:=1 to SystemHeader[i].Planets do begin
  5143.                   MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  5144.                   with MyPlanetHeader^ do begin
  5145.                      PName:='Tk'+NArr[random(6)]+NArr[random(20)+6];
  5146.                      if PFlags<>0 then begin
  5147.                         PFlags:=FLAG_OTHER;
  5148.                         Ethno:=FLAG_OTHER;
  5149.                         Biosphäre:=200;
  5150.                         Infrastruktur:=190;
  5151.                         Industrie:=180;
  5152.                         if ProjectPtr<>NIL then begin
  5153.                            ActPProject:=Ptr(ProjectPtr);
  5154.                            for k:=1 to 7 do
  5155.                             if (ActPProject^[i]>0) and (Save.ProjectCosts[8,i]=0) then ActPProject^[i]:=0
  5156.                             else Save.ProjectCosts[8,i]:=0;
  5157.                         end;
  5158.                         ProjectID:=-3;
  5159.                         if FirstShip.NextShip<>NIL then begin
  5160.                            MyShipPtr:=FirstShip.NextShip;
  5161.                            repeat
  5162.                               MyShipPtr^.Owner:=FLAG_OTHER;
  5163.                               MyShipPtr:=MyShipPtr^.NextShip;
  5164.                            until MyShipPtr=NIL;
  5165.                         end;
  5166.                      end;
  5167.                   end;
  5168.                end;
  5169.             end;
  5170.             for i:=1 to 25 do Save.TechCosts[8,i]:=0;
  5171.             WAITLOOP(false);
  5172.             RECT(MyScreen[1]^,0,50,100,460,175);
  5173.          end;
  5174.       4: begin   { ZEIT-ANOMALIE }
  5175.             PLAYSOUND(3,420);
  5176.             MAKEBORDER(MyScreen[1]^,50,100,460,175,12,6,0);
  5177.             WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Störung im Raum-Zeit-Kontinuum!');
  5178.             WRITE(256,130,ActPlayerFlag,16,MyScreen[1]^,4,'Allen Planeten des Quadranten melden');
  5179.             WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,'eine Zeitverschiebung von 79,1 Sekunden!');
  5180.             Save.WorldFlag:=WFLAG_FIELD;
  5181.             WAITLOOP(false);
  5182.             RECT(MyScreen[1]^,0,50,100,460,175);
  5183.          end;
  5184.    end;
  5185.    REFRESHDISPLAY;
  5186. end;
  5187.  
  5188.  
  5189.  
  5190.  
  5191. procedure MOVESHIP(ActSys :byte; ShipPtr:ptr; Visible :boolean);
  5192. forward;
  5193.  
  5194.  
  5195.  
  5196. procedure ORBITINFO(StShipPtr :ShipHeader; ReqText :str, ActSys :byte; XPosX,XPosY :short);
  5197.  
  5198. var MoreThanShown,b,FleetUsed   :boolean;
  5199. var ShipNames                   :array [1..12] of string[15];
  5200. var ShipFactor                  :byte;
  5201. var SelShip                     :word;
  5202. var BeforeMyShipPtr             :^r_ShipHeader;
  5203. var k,j                         :integer;
  5204. var MyShipPtr                   :^r_ShipHeader;
  5205.  
  5206.  
  5207. procedure DRAWSHIPS;
  5208.  
  5209. var j   :integer;
  5210.  
  5211. begin
  5212.    RECT(MyScreen[1]^,0,22,69,416,456);
  5213.    for j:=1 to 12 do ShipNames[j]:='';
  5214.    j:=1;
  5215.    repeat
  5216.       if MyShipPtr^.SType=SHIPTYPE_FLEET then DisplayBeep(NIL) else
  5217.       with MyShipPtr^ do if Owner<>0 then begin
  5218.          BltBitMapRastPort(^ImgBitMap4,(SType-8)*32,32,^MyScreen[1]^.RastPort,35,37+i*32,32,32,192);
  5219.          WRITE(72,45+i*32,12,0,MyScreen[1]^,4,Project[MyShipPtr^.SType]);
  5220.          ShipNames[j]:=Project[MyShipPtr^.SType];
  5221.          s:=intstr(round((MyShipPtr^.Shield+Tactical*3)/ShipData[MyShipPtr^.SType].MaxShield*100))+'%';
  5222.          while length(s)<4 do s:='0'+s;
  5223.          s:=intstr(MyShipPtr^.ShieldBonus)+' '+s;
  5224.          while length(s)<7 do s:='0'+s;
  5225.          s:=intstr(MyShipPtr^.Ladung and MASK_LTRUPPS)+' '+s;
  5226.          while length(s)<10 do s:='0'+s;
  5227.          s:=intstr((MyShipPtr^.Ladung and MASK_SIEDLER) div 16)+' '+s;
  5228.          while length(s)<13 do s:='0'+s;
  5229.          WRITE(235,45+i*32,8,0,MyScreen[1]^,2,s);
  5230.          i:=i+1;   j:=j+1;
  5231.       end;
  5232.       MyShipPtr:=MyShipPtr^.NextShip;
  5233.    until (MyShipPtr=NIL) or (i>12);
  5234. end;
  5235.  
  5236.  
  5237. procedure SETFLEETPOSITION;
  5238.  
  5239. begin
  5240.    MyShipPtr^.PosX:=StShipPtr^.PosX;
  5241.    MyShipPtr^.PosY:=StShipPtr^.PosY;
  5242.    MyShipPtr^.Moving:=StShipPtr^.Moving+1;
  5243.    MyShipPtr^.Target:=0;
  5244.    while FINDOBJECT(ActSys,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr)
  5245.    do with MyShipPtr^ do case random(4) of
  5246.       0: PosX:=PosX+1;
  5247.       1: PosX:=PosX-1;
  5248.       2: PosY:=PosY+1;
  5249.       3: PosY:=PosY-1;
  5250.    end;
  5251. end;
  5252.  
  5253.  
  5254.  
  5255. begin
  5256.    if StShipPtr=NIL then exit;
  5257.    MyShipPtr:=StShipPtr;
  5258.    while (MyShipPtr^.Owner=0) and (MyShipPtr^.NextShip<>NIL) do MyShipPtr:=MyShipPtr^.NextShip;
  5259.    if MyShipPtr^.Owner<>ActPlayerFlag then exit;
  5260.    if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  5261.       MyShipPtr:=MyShipPtr^.TargetShip;
  5262.       FleetUsed:=true;
  5263.    end else FleetUsed:=false;
  5264.    MAKEBORDER(MyScreen[1]^,20,30,420,480,12,6,0);
  5265.    s:=ReqText;
  5266.    WRITE(63,37,ActPlayerFlag,0,MyScreen[1]^,4,s);
  5267.    WRITE(36,56,12,0,MyScreen[1]^,1,'Schiff   Schiffstyp');
  5268.    WRITE(232,56,12,0,MyScreen[1]^,1,'Siedler  Landgtr.    Kampf.      Status');
  5269.    i:=1; ShipFactor:=0;
  5270.    DRAWSHIPS;
  5271.    if (i>12) and (MyShipPtr<>NIL) then begin
  5272.       MoreThanShown:=true;
  5273.       DrawImage(^MyScreen[1]^.RastPort,^GadImg1,300,457);
  5274.       WRITE(335,460,0,0,MyScreen[1]^,4,'Mehr');
  5275.    end else MoreThanShown:=false;
  5276.    b:=false;
  5277.    SelShip:=1; k:=0;
  5278.    repeat
  5279.       delay(RDELAY);
  5280.       if IBase^.MouseX in [60..370] then begin
  5281.          k:=(IBase^.MouseY-35) div 32;
  5282.          if k<>SelShip then begin
  5283.             for j:=1 to 12 do if j<>k then
  5284.              WRITE(72,45+j*32,12,0,MyScreen[1]^,4,ShipNames[j])
  5285.              else WRITE(72,45+j*32,ActPlayerFlag,0,MyScreen[1]^,4,ShipNames[j]);
  5286.             SelShip:=k;
  5287.          end;
  5288.       end;
  5289.       if (LData^ and 64=0) then begin
  5290.          if (IBase^.MouseX in [300..416]) and (IBase^.MouseY in [457..477]) then begin
  5291.             KLICKGAD(300,457);
  5292.             if MyShipPtr=NIL then begin
  5293.                MyShipPtr:=StShipPtr;
  5294.                if FleetUsed then MyShipPtr:=MyShipPtr^.TargetShip;
  5295.                i:=1; ShipFactor:=0;
  5296.             end else begin
  5297.                i:=i-12; ShipFactor:=ShipFactor+1;
  5298.             end;
  5299.             DRAWSHIPS;
  5300.          end else if IBase^.MouseX in [60..370] then begin
  5301.             PLAYSOUND(1,300);
  5302.             SelShip:=SelShip+ShipFactor*12;
  5303.             b:=true;
  5304.          end;
  5305.       end;
  5306.    until b or (RData^ and 1024=0);
  5307.    if (RData^ and 1024=0) then PLAYSOUND(1,300);
  5308.    RECT(MyScreen[1]^,0,20,30,422,482);
  5309.    if b then begin
  5310.       i:=1;
  5311.       MyShipPtr:=StShipPtr;
  5312.       while (MyShipPtr^.Owner=0) and (MyShipPtr^.NextShip<>NIL) do MyShipPtr:=MyShipPtr^.NextShip;
  5313.       if FleetUsed then MyShipPtr:=MyShipPtr^.TargetShip;
  5314.       while (i<>SelShip) and (MyShipPtr<>NIL) do begin
  5315.          if MyShipPtr^.Owner<>0 then i:=i+1;
  5316.          MyShipPtr:=MyShipPtr^.NextShip;
  5317.       end;
  5318.       if MyShipPtr<>NIL then begin
  5319.          if FleetUsed then begin
  5320.             SETFLEETPOSITION;
  5321.             if MyShipPtr=StShipPtr^.TargetShip then begin
  5322.                StShipPtr^.TargetShip:=MyShipPtr^.NextShip;
  5323.                if MyShipPtr^.NextShip<>NIL then MyShipPtr^.NextShip^.BeforeShip:=StShipPtr;
  5324.                LINKSHIP(MyShipPtr,^SystemHeader[ActSys].FirstShip,0);
  5325.             end else LINKSHIP(MyShipPtr,^SystemHeader[ActSys].FirstShip,1);
  5326.             if StShipPtr^.TargetShip^.NextShip=NIL then begin
  5327.                StShipPtr^.TargetShip^.PosX:=StShipPtr^.PosX;
  5328.                StShipPtr^.TargetShip^.PosY:=StShipPtr^.PosY;
  5329.                LINKSHIP(StShipPtr^.TargetShip,^SystemHeader[ActSys].FirstShip,0);
  5330.                StShipPtr^.Owner:=0;
  5331.                StShipPtr^.SType:=8;
  5332.             end;
  5333.          end else begin
  5334.             MyShipPtr^.PosX:=XPosX;
  5335.             MyShipPtr^.PosY:=XPosY;
  5336.             if FleetUsed then SETFLEETPOSITION;
  5337.             LINKSHIP(MyShipPtr,^SystemHeader[ActSys].FirstShip,1);
  5338.          end;
  5339.          REFRESHDISPLAY;
  5340.          if MyShipPtr^.Moving>0 then begin
  5341.             DRAWSYSTEM(MODE_REFRESH,ActSys,MyShipPtr);
  5342.             MOVESHIP(ActSys,MyShipPtr,false);
  5343.          end;
  5344.       end
  5345.    end;
  5346.    REFRESHDISPLAY;
  5347. end;
  5348.  
  5349.  
  5350.  
  5351. procedure KILLFLEET(MyShipPtr :ShipHeader);
  5352.  
  5353. var LastShipPtr :ShipHeader;
  5354.  
  5355. begin
  5356.    LastShipPtr:=MyShipPtr;
  5357.    MyShipPtr^.NextShip:=MyShipPtr^.TargetShip;
  5358.    MyShipPtr^.TargetShip^.BeforeShip:=MyShipPtr;
  5359.    while MyShipPtr<>NIL do begin
  5360.       MyShipPtr^.Owner:=LastShipPtr^.Owner;
  5361.       MyShipPtr:=MyShipPtr^.NextShip;
  5362.    end;
  5363.    MyShipPtr^.NextShip:=LastShipPtr^.NextShip;
  5364.    if LastShipPtr^.NextShip<>NIL then LastShipPtr^.NextShip^.BeforeShip:=MyShipPtr;
  5365.    LastShipPtr^.Owner:=0;
  5366. end;
  5367.  
  5368.  
  5369.  
  5370. procedure MOVESHIP;
  5371.  
  5372. var ToX,ToY,i,j,k,FromX,FromY           :integer;
  5373. var MyShipPtr,OtherShipPtr,FleetShipPtr :^r_ShipHeader;
  5374. var MyPlanetHeader                      :^r_PlanetHeader;
  5375. var l,x,y                               :long;
  5376. var b                                   :boolean;
  5377. var CivVar,CivFlag,OldMoving,SysID      :byte;
  5378. var ActPProjects                        :^ByteArr42;
  5379.  
  5380.  
  5381.  
  5382. procedure DRAWSCENE(ActSys :byte);
  5383.  
  5384. begin
  5385.    if ActSys<>Display then begin
  5386.       OffsetX:=-MyShipPtr^.PosX-1;
  5387.       OffsetY:=-MyShipPtr^.PosY-1;
  5388.       x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  5389.       y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  5390.       DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  5391.    end else REFRESHDISPLAY;
  5392.    delay(10);
  5393. end;
  5394.  
  5395.  
  5396.  
  5397. procedure EXPLODE(ActSys :byte; MyShipPtr :ShipHeader);
  5398.  
  5399. begin
  5400.    if ActSys<>0 then begin
  5401.       if ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN) and (MyShipPtr<>NIL)
  5402.       and (Save.CivPlayer[ActPlayer]<>0))
  5403.       or ((GETCIVVAR(SystemFlags[1,ActSys])<>0)
  5404.           and (Save.CivPlayer[GETCIVVAR(SystemFlags[1,ActSys])]<>0)) then with MyShipPtr^ do begin
  5405.          DRAWSCENE(ActSys);
  5406.          PLAYSOUND(2,1100);
  5407.          x:=256+(PosX+OffsetX)*32;
  5408.          y:=256+(PosY+OffsetY)*32;
  5409.          if not ((PosX=0) and (PosY=0)) then begin
  5410.             PosX:=FromX;   PosY:=FromY;
  5411.          end;
  5412.          if (x in [0..480]) and (y in [0..480]) and not ((PosX=0) and (PosY=0)) then begin
  5413.             RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  5414.             for i:=0 to 15 do begin
  5415.                BltBitMapRastPort(^ImgBitMap4,i*32,0,^MyScreen[1]^.RastPort,x,y,31,31,192);
  5416.                delay(5);
  5417.             end;
  5418.             RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  5419.             delay(10);
  5420.             DMACON_WRITE^:=$0003;
  5421.          end;
  5422.       end;
  5423.    end;
  5424.    if MyShipPtr<>NIL then begin
  5425.       MyShipPtr^.Owner:=0;
  5426.       MyShipPtr^.Moving:=0;
  5427.    end;
  5428.    REFRESHDISPLAY;
  5429.    delay(10);
  5430. end;
  5431.  
  5432.  
  5433.  
  5434. procedure SMALLANDING(PPtr,SPtr :ptr; ActSys :byte);
  5435.  
  5436. var MyShipPtr                           :^r_ShipHeader;
  5437. var MyPlanetHeader                      :^r_PlanetHeader;
  5438. var ActPProjects                        :^ByteArr42;
  5439. var ShipShield,ShipWeapon,GroundWeapon  :integer;
  5440. var LandShield                          :integer;
  5441. var Visible                             :boolean;
  5442. var HitCtr                              :byte;
  5443. var l                                   :long;
  5444. var Percs                               :real;
  5445.  
  5446. begin
  5447.    MyPlanetHeader:=PPtr;
  5448.    MyShipPtr:=ShipPtr;
  5449.    HitCtr:=0;
  5450.    if (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0)
  5451.    or ((MyPlanetHeader^.PFlags>0) and (Save.CivPlayer[GETCIVVAR(MyPlanetHeader^.PFlags)]<>0))
  5452.    or (Display=ActSys) then Visible:=true else Visible:=false;
  5453.    with MyPlanetHeader^ do begin
  5454.       ActPPRojects:=ProjectPtr;
  5455.       ShipShield:=(MyShipPtr^.Shield+MyShipPtr^.Tactical*3+MyShipPtr^.ShieldBonus);
  5456.       ShipWeapon:=round((MyShipPtr^.Weapon/10+1)*ShipData[MyShipPtr^.SType].WeaponPower-MyShipPtr^.Tactical);
  5457.       CivVar:=GETCIVVAR(MyPlanetHeader^.PFlags);
  5458.       if CivVar<>0 then begin
  5459.          GroundWeapon:=WEAPON_GUN;
  5460.          if Save.TechCosts[CivVar,15]=0 then GroundWeapon:=WEAPON_LASER;
  5461.          if Save.TechCosts[CivVar,24]=0 then GroundWeapon:=WEAPON_PHASER;
  5462.          if Save.TechCosts[CivVar,32]=0 then GroundWeapon:=WEAPON_DISRUPTOR;
  5463.          if Save.TechCosts[CivVar,27]=0 then GroundWeapon:=WEAPON_PTORPEDO;
  5464.       end else GroundWeapon:=WEAPON_PTORPEDO;
  5465.       randomize;
  5466.  
  5467.       if ActPProjects^[34]>0 then begin
  5468.          LandShield:=round(16*ActPProjects^[34]/10);
  5469.          repeat
  5470.             case random(5) of
  5471.                0: ShipShield:=ShipShield-GroundWeapon;
  5472.                otherwise begin
  5473.                   LandShield:=LandShield-ShipWeapon;
  5474.                   HitCtr:=HitCtr+1;
  5475.                end;
  5476.             end;
  5477.          until (ShipShield<0) or (LandShield<0);
  5478.          if LandShield<=0 then begin
  5479.             ActPProjects^[34]:=0;
  5480.             if Visible then PLAYSOUND(2,1100);
  5481.          end else ActPPRojects^[34]:=round(LandShield*100/9/10);
  5482.       end;
  5483.  
  5484.       if (ActPProjects^[40]>0) and (ShipShield>=0) then begin
  5485.          delay(20);
  5486.          LandShield:=round(64*ActPProjects^[40]/10);
  5487.          repeat
  5488.             case random(5) of
  5489.                0: ShipShield:=ShipShield-GroundWeapon;
  5490.                otherwise begin
  5491.                   LandShield:=LandShield-ShipWeapon;
  5492.                   HitCtr:=HitCtr+1;
  5493.                end;
  5494.             end;
  5495.          until (ShipShield<0) or (LandShield<0);
  5496.          if LandShield<=0 then begin
  5497.             ActPProjects^[40]:=0;
  5498.             if Visible then PLAYSOUND(2,1100);
  5499.          end else ActPPRojects^[40]:=round(LandShield*100/49/10);
  5500.       end;
  5501.  
  5502.       if ShipShield>=0 then with MyShipPtr^ do begin
  5503.          if ShipShield-ShieldBonus-Tactical*3>0 then
  5504.           Shield:=ShipShield-ShieldBonus-Tactical*3 else Shield:=1;
  5505.          ShieldBonus:=ShieldBonus+1;
  5506.          REFRESHDISPLAY;
  5507.          delay(10);
  5508.       end else begin
  5509.          if Visible then EXPLODE(ActSys,MyShipPtr);
  5510.          MyShipPtr^.Owner:=0;
  5511.       end;
  5512.    end;
  5513. end;
  5514.  
  5515.  
  5516.  
  5517. procedure STARLANDING(PPtr,SPtr :ptr; ActSys: byte);
  5518.  
  5519. var NeuScreen                           :NewScreen;
  5520. var ImgBitMap5                          :ITBitMap;
  5521. var l                                   :long;
  5522. var i,j,k                               :integer;
  5523. var AScr,DefaultColor,CivVar            :byte;
  5524. var SLSoundMemA                         :long;
  5525. var SLSoundSize                         :word;
  5526. var ShipShield,ShipWeapon,
  5527.     GroundWeapon                        :integer;
  5528. var MyPlanetHeader                      :^r_PlanetHeader;
  5529. var MyShipPtr                           :^r_ShipHeader;
  5530. var Percs                               :real;
  5531. var ActPProjects                        :^ByteArr42;
  5532.  
  5533.  
  5534. function INITIMAGES:boolean;
  5535.  
  5536. var ISize       :long;
  5537.  
  5538. begin
  5539.    INITIMAGES:=false;
  5540.    case MyPlanetHeader^.Class of
  5541.       CLASS_DESERT:   s:='D';
  5542.       CLASS_HALFEARTH:s:='H';
  5543.       CLASS_EARTH:    s:='M';
  5544.       CLASS_ICE:      s:='I';
  5545.       CLASS_STONES:   s:='T';
  5546.       CLASS_WATER:    s:='W';
  5547.    end;
  5548.    s:=PathStr[1]+'LandScape'+s+'.img';
  5549.    if not RAWLOADIMAGE(s,0,0,640,32,5,ImgBitMap5) then exit;
  5550.  
  5551.    s[length(s)-3]:=chr(0); s:=s+'.pal';
  5552.    i:=SETCOLOR(MyScreen[1]^,s);
  5553.    i:=SETCOLOR(MyScreen[2]^,s);
  5554.  
  5555.    case MyShipPtr^.Weapon of
  5556.       WEAPON_GUN:       s:='Gun';
  5557.       WEAPON_LASER:     s:='Laser';
  5558.       WEAPON_PHASER:    s:='Phaser';
  5559.       WEAPON_DISRUPTOR: s:='Disruptor';
  5560.       WEAPON_PTORPEDO:  s:='PTorpedo';
  5561.    end;
  5562.    s:=PathStr[7]+s+'.RAW';
  5563.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  5564.    if FHandle=0 then exit;
  5565.    SLSoundSize:=DosSeek(FHandle,0,OFFSET_END);
  5566.    SLSoundSize:=DosSeek(FHandle,0,OFFSET_BEGINNING) div 2;
  5567.    SLSoundMemA:=IMemA[0];
  5568.    l:=DosRead(FHandle,ptr(SLSoundMemA),SLSoundSize*2);
  5569.    DosClose(FHandle);
  5570.    INITIMAGES:=true;
  5571. end;
  5572.  
  5573.  
  5574.  
  5575. procedure LANDING;
  5576.  
  5577. const ID_WATER=    -1;
  5578. const ID_WOOD=      0;
  5579. const ID_GRASS=    32;
  5580. const ID_DESERT=   64;
  5581. const ID_HILLS=    96;
  5582. const ID_SPHALANX=128;
  5583. const ID_SDI=     160;
  5584. const ID_CITY1=   192;
  5585. const ID_CITY2=   224;
  5586. const ID_LAKE=    256;
  5587. const ID_UFER_OUT=288;
  5588. const ID_UFER_IN= 320;
  5589.  
  5590.  
  5591. var Moved                               :array [1..2] of integer;
  5592. var LandID,LandShield                   :array [0..7,0..7] of integer;
  5593. var HitX,HitY,Fired                     :short;
  5594. var SDIBases,SPHBases                   :integer;
  5595. var SDIBaseDrawed,SPHBaseDrawed,
  5596.     SDIBaseHit,SPHBaseHit,CityDrawed,
  5597.     CityHit,BioDrawed,BioHit,CityComp   :long;
  5598.  
  5599.  
  5600. procedure DRAWFIRE;
  5601.  
  5602. begin
  5603.    SPAddrA^:=ZeroSound; SPLengthA^:=1;
  5604.    SPAddrB^:=ZeroSound; SPLengthB^:=1;
  5605.    SPAddrC^:=ZeroSound; SPLengthC^:=1;
  5606.    SPAddrD^:=ZeroSound; SPLengthD^:=1;
  5607.    if (HitX>-1) and (HitY>-1) then begin
  5608.       LandID[HitX,HitY]:=LandID[HitX,HitY]+32;
  5609.       BltBitMapRastPort(^ImgBitMap5,LandID[HitX,HitY],0,^MyScreen[AScr]^.RastPort,HitX*32,HitY*32-Moved[Ascr],32,32,192);
  5610.       if LandID[HitX,HitY]=608 then begin
  5611.          if Moved[3-Ascr]>0 then
  5612.             BltBitMapRastPort(^ImgBitMap5,LandID[HitX,HitY],0,^MyScreen[3-AScr]^.RastPort,HitX*32,HitY*32-Moved[3-Ascr],32,32,192)
  5613.          else
  5614.             BltBitMapRastPort(^ImgBitMap5,LandID[HitX,HitY],0,^MyScreen[3-AScr]^.RastPort,HitX*32,HitY*32-32,32,32,192);
  5615.          HitX:=-1; HitY:=-1;
  5616.       end;
  5617.    end;
  5618.    if Fired>0 then Fired:=Fired-1 else if (LData^ and 64=0) and (IBase^.MouseY in [65..382]) then begin
  5619.       Fired:=7;
  5620.       DMACON_WRITE^:=$000C;
  5621.       SPAddrC^:=SLSoundMemA; SPFreqC^:=350; SPLengthC^:=SLSoundSize; SPVolC^:=50;
  5622.       SPAddrD^:=SLSoundMemA; SPFreqD^:=300; SPLengthD^:=SLSoundSize; SPVolD^:=50;
  5623.       DMACON_WRITE^:=$800C;
  5624.       HitX:=(IBase^.MouseX-32) div 64; HitY:=(IBase^.MouseY div 2 + Moved[AScr]) div 32;
  5625.       LandShield[HitX,HitY]:=LandShield[HitX,HitY]-ShipWeapon;
  5626.       if ((LandID[HitX,HitY] in [ID_SDI,ID_SPHALANX]) and (LandShield[HitX,HitY]<0))
  5627.       or (LandID[HitX,HitY] in [ID_WOOD,ID_GRASS,ID_DESERT,ID_HILLS,ID_CITY2,ID_CITY1]) then begin
  5628.          if LandID[HitX,HitY]=ID_SDI then SDIBaseHit:=SDIBaseHit+1
  5629.          else if LandID[HitX,HitY]=ID_SPHALANX then SPHBaseHit:=SPHBaseHit+1
  5630.          else if LandID[HitX,HitY] in [ID_CITY1,ID_CITY2] then CityHit:=CityHit+1
  5631.          else BioHit:=BioHit+1;
  5632.          PLAYSOUND(2,800);
  5633.          LandID[HitX,HitY]:=352;
  5634.          BltBitMapRastPort(^ImgBitMap5,352,0,^MyScreen[AScr]^.RastPort,HitX*32,HitY*32-Moved[Ascr],32,32,192);
  5635.       end else begin
  5636.          HitX:=-1; HitY:=-1;
  5637.       end;
  5638.    end;
  5639. end;
  5640.  
  5641.  
  5642.  
  5643. begin
  5644.    for i:=1 to 2 do begin
  5645.       RECT(MyScreen[i]^,DefaultColor,0,0,255,240);
  5646.       RECT(MyScreen[i]^,12,0,244,255,255);
  5647.       if ShipShield<255 then RECT(MyScreen[i]^,0,ShipShield,245,254,254);
  5648.    end;
  5649.    for i:=0 to 7 do for j:=0 to 7 do begin
  5650.       LandID[j,i]:=ID_WATER; LandShield[j,i]:=0;
  5651.    end;
  5652.    for i:=0 to 7 do LandID[i,0]:=ID_UFER_IN;
  5653.    Moved[AScr]:=32; Moved[3-AScr]:=30; Fired:=0;
  5654.    HitX:=-1;        HitY:=-1;
  5655.    SDIBases:=0;      SPHBases:=0;
  5656.    SDIBaseDrawed:=0; SPHBaseDrawed:=0;
  5657.    SDIBaseHit:=0;    SPHBaseHIT:=0;
  5658.    CityDrawed:=0;    CityHit:=0;
  5659.    BioDrawed:=0;     BioHit:=0;
  5660.    CityComp:=MyPlanetHeader^.Population div 300+1;
  5661.    if CityComp>30 then CityComp:=30;
  5662.    repeat                      { MOVE UFER_IN }
  5663.       SDIBases:=SDIBases+1;
  5664.       Moved[Ascr]:=Moved[AScr]-4;
  5665.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5666.       for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],Moved[AScr],^MyScreen[AScr]^.RastPort,i*32,0,32,4,192);
  5667.       DRAWFIRE;
  5668.       ScreenToFront(MyScreen[AScr]);
  5669.       AScr:=3-AScr;
  5670.    until SDIBases>=14;
  5671.  
  5672.    SDIBases:=(ActPProjects^[34] div 10)-1;
  5673.    SPHBases:=(ActPProjects^[40] div 10)-1;
  5674.  
  5675.    repeat                      { MOVE LANDSCAPE AND BATTLE }
  5676.       Moved[Ascr]:=Moved[AScr]-4;
  5677.       if Moved[AScr]<0 then Moved[Ascr]:=Moved[Ascr]+32;
  5678.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5679.       SetRGB32(^MyScreen[AScr]^.ViewPort,0,0,0,0);
  5680.       if Moved[AScr]=30 then begin
  5681.          for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0], 0,^MyScreen[AScr]^.RastPort,i*32,2,32,2,192);
  5682.          for i:=0 to 7 do begin
  5683.             if LandID[i,7] in [ID_SDI,ID_SPHALANX] then begin
  5684.                SetRGB32(^MyScreen[AScr]^.ViewPort,0,$FF000000,$FF000000,$FF000000);
  5685.                PLAYSOUND(2,400);
  5686.                ShipShield:=ShipShield-GroundWeapon;
  5687.                if ShipShield<0 then ShipShield:=0;
  5688.                if ShipShield in [0..255] then for k:=1 to 2 do RECT(MyScreen[k]^,0,ShipShield,245,254,254);
  5689.             end;
  5690.             for j:=6 downto 0 do begin
  5691.                LandID[i,succ(j)]:=LandID[i,j];
  5692.                LandShield[i,succ(j)]:=LandShield[i,j];
  5693.             end;
  5694.          end;
  5695.          for i:=0 to 7 do begin
  5696.             LandShield[i,0]:=0;
  5697.             if (Random(5)=0) or (CityDrawed>CityComp) then begin
  5698.                LandID[i,0]:=random(9)*32;
  5699.                case LandID[i,0] of
  5700.                   ID_SDI:      if SDIBases<0 then LandID[i,0]:=ID_CITY1
  5701.                                else begin
  5702.                                   SDIBases:=SDIBases-1;
  5703.                                   SDIBaseDrawed:=SDIBaseDrawed+1;
  5704.                                   LandShield[i,0]:=18;
  5705.                                end;
  5706.                   ID_SPHALANX: if SPHBases<0 then LandID[i,0]:=ID_CITY2
  5707.                                else begin
  5708.                                   SPHBases:=SPHBases-1;
  5709.                                   SPHBaseDrawed:=SPHBaseDrawed+1;
  5710.                                   LandShield[i,0]:=72;
  5711.                                end;
  5712.                   otherwise;
  5713.                end;
  5714.                if LandID[i,0] in [ID_CITY1,ID_CITY2] then CityDrawed:=CityDrawed+1
  5715.                 else if LandID[i,0] in [ID_WOOD..ID_HILLS] then BioDrawed:=BioDrawed+1;
  5716.             end else begin
  5717.                if (MyPlanetHeader^.Biosphäre<190) and (random(100)<5) then LandID[i,0]:=608 else begin
  5718.                   LandID[i,0]:=random(3)*32;
  5719.                   BioDrawed:=BioDrawed+1;
  5720.                end;
  5721.             end;
  5722.          end;
  5723.          for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],30,^MyScreen[AScr]^.RastPort,i*32,0,32,2,192);
  5724.          if HitY>-1 then begin
  5725.             HitY:=HitY+1;
  5726.             if HitY=8 then HitY:=0;
  5727.          end;
  5728.       end else for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],Moved[AScr],^MyScreen[AScr]^.RastPort,i*32,0,32,4,192);
  5729.       DRAWFIRE;
  5730.       ScreenToFront(MyScreen[AScr]);
  5731.       AScr:=3-AScr;
  5732.       if (SDIBases<0) and (SPHBases<0) then SDIBases:=SDIBases-1;
  5733.    until ((ShipShield<=0) or ((SDIBases<-160) and (CityDrawed>CityComp))) and (Ascr=1);
  5734.  
  5735.    if ShipShield<0 then begin                { DESTROYED SHIP }
  5736.       MyShipPtr^.Owner:=0;
  5737.       DMACON_WRITE^:=$000F;
  5738.       SetRGB32(^MyScreen[1]^.ViewPort,0,$FF000000,$FF000000,$FF000000);
  5739.       RECT(MyScreen[1]^,0,0,0,255,255);
  5740.       PLAYSOUND(2,1000);
  5741.       SPAddrD^:=SoundMemA[2]+SoundSize[2]; SPFreqD^:=900; SPLengthD^:=SoundSize[2] div 2; SPVolD^:=64;
  5742.       SPAddrC^:=SoundMemA[2];              SPFreqC^:=900; SPLengthC^:=SoundSize[2] div 2; SPVolC^:=64;
  5743.  
  5744.       ScreenToFront(MyScreen[AScr]);
  5745.       AScr:=3-AScr;         WaitTOF;
  5746.       SPAddrA^:=ZeroSound; SPLengthA^:=1;
  5747.  
  5748.       ScreenToFront(MyScreen[AScr]);
  5749.       AScr:=3-AScr;         WaitTOF;
  5750.       SPAddrB^:=ZeroSound; SPLengthB^:=1;
  5751.  
  5752.       DMACON_WRITE^:=$800C;
  5753.       ScreenToFront(MyScreen[AScr]);
  5754.       AScr:=3-AScr;         WaitTOF;
  5755.       SPAddrD^:=ZeroSound; SPLengthD^:=1;
  5756.  
  5757.       ScreenToFront(MyScreen[AScr]);
  5758.       AScr:=3-AScr;         WaitTOF;
  5759.       SPAddrC^:=ZeroSound; SPLengthC^:=1;
  5760.  
  5761.       for i:=1 to 20 do begin
  5762.          ScreenToFront(MyScreen[AScr]);
  5763.          AScr:=3-AScr;         WaitTOF;
  5764.       end;
  5765.  
  5766.    end else begin                            { MOVE UFER_OUT }
  5767.       if Moved[Ascr]-4>0 then begin
  5768.          repeat
  5769.             Moved[Ascr]:=Moved[AScr]-4;
  5770.             ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5771.             for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],Moved[AScr],^MyScreen[AScr]^.RastPort,i*32,0,32,4,192);
  5772.             DRAWFIRE;
  5773.             ScreenToFront(MyScreen[AScr]);
  5774.             AScr:=3-AScr;
  5775.          until Moved[Ascr]-4<0;
  5776.       end;
  5777.  
  5778.       SDIBases:=0;
  5779.  
  5780.       Moved[Ascr]:=Moved[AScr]+28;
  5781.       ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5782.       for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0], 0,^MyScreen[AScr]^.RastPort,i*32,2,32,2,192);
  5783.       for i:=0 to 7 do begin
  5784.          for j:=6 downto 0 do begin
  5785.             LandID[i,succ(j)]:=LandID[i,j];
  5786.             LandShield[i,succ(j)]:=LandShield[i,j];
  5787.          end;
  5788.          LandID[i,0]:=ID_UFER_OUT;
  5789.       end;
  5790.       if HitY>-1 then begin
  5791.          HitY:=HitY+1;
  5792.          if HitY=8 then HitY:=0;
  5793.       end;
  5794.       for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],30,^MyScreen[AScr]^.RastPort,i*32,0,32,2,192);
  5795.       DRAWFIRE;
  5796.       ScreenToFront(MyScreen[AScr]);
  5797.       AScr:=3-AScr;
  5798.       repeat
  5799.          SDIBases:=SDIBases+1;
  5800.          Moved[Ascr]:=Moved[AScr]-4;
  5801.          if Moved[AScr]<0 then Moved[Ascr]:=Moved[Ascr]+32;
  5802.          if Moved[AScr]=30 then begin
  5803.             for i:=0 to 7 do begin
  5804.                for j:=6 downto 0 do begin
  5805.                   LandID[i,succ(j)]:=LandID[i,j];
  5806.                   LandShield[i,succ(j)]:=LandShield[i,j];
  5807.                end;
  5808.                LandID[i,0]:=ID_WATER;
  5809.             end;
  5810.             if HitY>-1 then begin
  5811.                HitY:=HitY+1;
  5812.                if HitY=8 then HitY:=0;
  5813.             end;
  5814.          end;
  5815.          ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5816.          for i:=0 to 7 do BltBitMapRastPort(^ImgBitMap5,LandID[i,0],Moved[AScr],^MyScreen[AScr]^.RastPort,i*32,0,32,4,192);
  5817.          DRAWFIRE;
  5818.          ScreenToFront(MyScreen[AScr]);
  5819.          AScr:=3-AScr;
  5820.       until SDIBases>=14;
  5821.  
  5822.       for i:=1 to 128 do begin
  5823.          Moved[Ascr]:=Moved[AScr]-4;
  5824.          if Moved[AScr]<0 then Moved[Ascr]:=Moved[Ascr]+32;
  5825.          if Moved[Ascr]=30 then begin
  5826.             for i:=0 to 7 do begin
  5827.                LandID[i,0]:=ID_WATER;
  5828.                for j:=6 downto 0 do begin
  5829.                   LandID[i,succ(j)]:=LandID[i,j];
  5830.                   LandShield[i,succ(j)]:=LandShield[i,j];
  5831.                end;
  5832.             end;
  5833.             if HitY>-1 then begin
  5834.                HitY:=HitY+1;
  5835.                if HitY=8 then HitY:=0;
  5836.             end;
  5837.          end;
  5838.          ScrollRaster(^MyScreen[AScr]^.RastPort,0,-4,0,0,255,240);
  5839.          RECT(MyScreen[Ascr]^,DefaultColor,0,0,255,4);
  5840.          DRAWFIRE;
  5841.          ScreenToFront(MyScreen[AScr]);
  5842.          AScr:=3-AScr;
  5843.       end;
  5844.    end;
  5845.    BioDrawed:=BioDrawed+CityDrawed+SDIBaseDrawed+SPHBaseDrawed;
  5846.    BioHit:=BioHit+CityHit+SDIBaseHit+SPHBaseHit;
  5847.    with MyPlanetHeader^ do begin
  5848.       s:=PathStr[1]+'Paper.pal';
  5849.       l:=SETCOLOR(MyScreen[AScr]^,s);
  5850.       s:=PathStr[1]+'Paper.img';
  5851.       if not DISPLAYIMAGE(s,0,0,256,256,5,MyScreen[AScr]^,0) then begin end;
  5852.       if SDIBaseDrawed>0 then ActPProjects^[34]:=ActPPRojects^[34]-(SDIBaseHit*ActPProjects^[34] div SDIBaseDrawed);
  5853.       if SPHBaseDrawed>0 then ActPPRojects^[40]:=ActPPRojects^[40]-(SPHBaseHit*ActPProjects^[40] div SPHBaseDrawed);
  5854.       if (SDIBaseDrawed>0) and (SPHBaseDrawed>0) then begin
  5855.          CityDrawed:=CityDrawed*20+SDIBaseDrawed+SPHBaseDrawed;
  5856.          CityHit:=CityHit*20+SDIBaseHit+SPHBaseHit;
  5857.       end;
  5858.       if CityHit=0 then Percs:=1 else Percs:=1-(CityHit/CityDrawed);
  5859.       if Percs<0.8 then begin
  5860.          Ethno:=PFlags and FLAG_CIV_MASK;
  5861.          Save.ImperatorState[ActPlayer]:=round(Save.ImperatorState[ActPlayer]*Percs);
  5862.       end;
  5863.  
  5864.       s:='Bevölkerung: '+intstr(Population)+' -> ';
  5865.       Population:=round(Population*Percs);
  5866.       if (Percs>0) and (Population<=0) then Population:=1;
  5867.       s:=s+intstr(Population)+' ('+intstr(round(Percs*100))+'%)';
  5868.       WRITE(22,40,29,0,MyScreen[Ascr]^,1,s);
  5869.  
  5870.       s:='Infrastruktur: '+intstr(Infrastruktur div 2)+'% -> ';
  5871.       Infrastruktur:=Infrastruktur-(CityHit*Infrastruktur div CityDrawed);
  5872.       s:=s+intstr(Infrastruktur div 2)+'%';
  5873.       WRITE(22,55,29,0,MyScreen[Ascr]^,1,s);
  5874.  
  5875.       s:='Industrie: '+intstr(Industrie div 2)+'% -> ';
  5876.       Industrie:=    Industrie-    (CityHit*Industrie     div CityDrawed);
  5877.       s:=s+intstr(Industrie div 2)+'%';
  5878.       WRITE(22,70,29,0,MyScreen[Ascr]^,1,s);
  5879.  
  5880.       s:='Biosphäre: '+intstr(Biosphäre div 2)+'% -> ';
  5881.       Biosphäre:=    Biosphäre-    (BioHit* Biosphäre     div BioDrawed);
  5882.       s:=s+intstr(Biosphäre div 2)+'%';
  5883.       WRITE(22,85,29,0,MyScreen[Ascr]^,1,s);
  5884.  
  5885.       s:='Neuer Imperatorstatus: '+intstr(Save.ImperatorState[ActPlayer])+' Punkte';
  5886.       WRITE(22,120,29,0,MyScreen[Ascr]^,1,s);
  5887.       ScreenToFront(MyScreen[Ascr]);
  5888.       WAITLOOP(false);
  5889.    end;
  5890. end;
  5891.  
  5892.  
  5893.  
  5894. procedure STARLANDINGEXIT(Error :boolean);
  5895.  
  5896. begin
  5897.    DoClock:=false;
  5898.    if ImgBitMap5.MemA<>0 then FreeMem(ImgBitMap5.MemA,ImgBitMap5.MemL);
  5899.    ImgBitMap5.MemA:=0;
  5900.    CLOSEMYSCREENS;
  5901.    DMACON_WRITE^:=$000F;
  5902.    b:=OPENMAINSCREENS;
  5903.    b:=INITDESK(0);
  5904.    Screen2:=0;
  5905.    if Error then SMALLANDING(PPtr,SPtr,ActSys);
  5906.    DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  5907. end;
  5908.  
  5909.  
  5910.  
  5911. begin
  5912.    if Save.SmallLand then begin
  5913.       SMALLANDING(PPtr,SPtr,ActSys);
  5914.       exit;
  5915.    end;
  5916.    MyPlanetHeader:=PPtr; MyShipPtr:=SPtr;
  5917.    ActPProjects:=MyPlanetHeader^.ProjectPtr;
  5918.    CLOSEMYSCREENS;
  5919.    Display:=100;
  5920.    ImgBitMap5:=ITBitMap(0,0,0,0,0,NIL,NIL,NIL,NIL,NIL,NIL,NIL,NIL,0,0);
  5921.    with ImgBitMap5 do begin
  5922.       MemL:=13600;  {640 x 34 x 5}
  5923.       MemA:=AllocMem(MemL,MEMF_CHIP+MEMF_CLEAR);
  5924.       if MemA=0 then exit;
  5925.       ImgBitMap5:=ITBitMap(80,34,1,5,0,ptr(MemA),     ptr(MemA+2720),ptr(MemA+5440),
  5926.                                        ptr(MemA+8160),ptr(MemA+10880),
  5927.                                        NIL,NIL,NIL,MemA,MemL);
  5928.    end;
  5929.    Tags:=TagArr(SA_DisplayID,   ($1000+HelpID),
  5930.                 SA_Interleaved, _TRUE,
  5931.                 SA_Draggable,   _FALSE,
  5932.                 SA_COLORS,      addr(ColSpec),
  5933.                 TAG_DONE,       0,0,0,0,0);
  5934.    NeuScreen:=NewScreen(16,0,256,256,5,0,0,0,CUSTOMSCREEN+SCREENQUIET,
  5935.                         NIL,'',NIL,NIL);
  5936.    for i:=1 to 2 do MyScreen[i]:=OpenScreenTagList(^NeuScreen,^Tags);
  5937.    if MyScreen[1]=NIL then begin
  5938.       STARLANDINGEXIT(true); exit;
  5939.    end;
  5940.    if MyScreen[2]=NIL then begin
  5941.       STARLANDINGEXIT(true); exit;
  5942.    end;
  5943.    SWITCHDISPLAY;
  5944.    if not INITIMAGES then begin
  5945.       STARLANDINGEXIT(true); exit;
  5946.    end;
  5947.    BltBitMapRastPort(^ImgBitMap5,304,0,^MyScreen[1]^.RastPort,0,0,1,1,192);
  5948.    DefaultColor:=ReadPixel(^MyScreen[1]^.RastPort,0,0);
  5949.    AScr:=2;
  5950.  
  5951.    ShipShield:=(MyShipPtr^.Shield+MyShipPtr^.Tactical*3+MyShipPtr^.ShieldBonus);
  5952.    ShipWeapon:=round((MyShipPtr^.Weapon/10+1)*ShipData[MyShipPtr^.SType].WeaponPower-MyShipPtr^.Tactical);
  5953.    CivVar:=GETCIVVAR(MyPlanetHeader^.PFlags);
  5954.    if CivVar<>0 then begin
  5955.       GroundWeapon:=WEAPON_GUN;
  5956.       if Save.TechCosts[CivVar,15]=0 then GroundWeapon:=WEAPON_LASER;
  5957.       if Save.TechCosts[CivVar,24]=0 then GroundWeapon:=WEAPON_PHASER;
  5958.       if Save.TechCosts[CivVar,32]=0 then GroundWeapon:=WEAPON_DISRUPTOR;
  5959.       if Save.TechCosts[CivVar,27]=0 then GroundWeapon:=WEAPON_PTORPEDO;
  5960.    end else GroundWeapon:=WEAPON_PTORPEDO;
  5961.    GroundWeapon:=GroundWeapon*3;
  5962.    LANDING;
  5963.    STARLANDINGEXIT(false);
  5964.    if ShipShield>0 then with MyShipPtr^ do begin
  5965.       if ShipShield-ShieldBonus-Tactical*3>0 then
  5966.        Shield:=ShipShield-ShieldBonus-Tactical*3 else Shield:=1;
  5967.       ShieldBonus:=ShieldBonus+1;
  5968.    end else MyShipPtr^.Owner:=0;
  5969. end;
  5970.  
  5971.  
  5972.  
  5973.  
  5974. function BIGSHIPFIGHT(Ship1,Ship2 :ShipHeader; Mode,ActSys :byte):byte;
  5975.  
  5976. type r_SmallShipHeader=record
  5977.    ShieldS,WeaponS        :integer;
  5978. end;
  5979.  
  5980. var SSHeader                    :array [0..1] of r_SmallShipHeader;
  5981. var l                           :long;
  5982. var i,j                         :integer;
  5983. var AScr                        :byte;
  5984. var BSFSoundMemA                :array [2..4] of long;
  5985. var BSFSoundSize                :array [2..4] of word;
  5986. var ShipPtr1,ShipPtr2           :^r_ShipHeader;
  5987. var Visible                     :boolean;
  5988.  
  5989.  
  5990. function INITIMAGES:boolean;
  5991.  
  5992. var ISize               :long;
  5993.  
  5994. function LOADSAMPLE(FName :str; SID :byte):boolean;
  5995.  
  5996. begin
  5997.    LOADSAMPLE:=false;
  5998.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  5999.    if FHandle=0 then exit;
  6000.    l:=DosSeek(FHandle,0,OFFSET_END);
  6001.    l:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  6002.    BSFSoundSize[SID]:=l div 2;
  6003.    l:=DosRead(FHandle,ptr(BSFSoundMemA[SID]),BSFSoundSize[SID]*2);
  6004.    DosClose(FHandle);
  6005.    LOADSAMPLE:=true;
  6006. end;
  6007.  
  6008.  
  6009. procedure INITSOUNDNAMES(SoundID :byte);
  6010.  
  6011. begin
  6012.    case SoundID of
  6013.       WEAPON_GUN:       s:='Gun';
  6014.       WEAPON_LASER:     s:='Laser';
  6015.       WEAPON_PHASER:    s:='Phaser';
  6016.       WEAPON_DISRUPTOR: s:='Disruptor';
  6017.       WEAPON_PTORPEDO:  s:='PTorpedo';
  6018.       otherwise;
  6019.    end;
  6020.    s:=PathStr[7]+'ST/'+s+'.RAW';    {SFX/}
  6021. end;
  6022.  
  6023.  
  6024. begin
  6025.    INITIMAGES:=false;
  6026.    s:=PathStr[6]+'ST/'+Project[ShipPtr1^.SType]+'.img';       { SHIPS/ }
  6027.    if ShipPtr1^.SType=27 then s:=PathStr[6]+'ST/Borg.img';
  6028.    if not RAWLOADIMAGE(s,0,32,512,32,4,ImgBitMap4) then exit;
  6029.    s:=PathStr[6]+'ST/'+Project[ShipPtr2^.SType]+'.img';       { SHIPS/ }
  6030.    if ShipPtr2^.SType=27 then s:=PathStr[6]+'ST/Borg.img';
  6031.    if not RAWLOADIMAGE(s,0,64,512,32,4,ImgBitMap4) then exit;
  6032.  
  6033.    BSFSoundMemA[2]:=IMemA[0];
  6034.    INITSOUNDNAMES(ShipPtr1^.Weapon);
  6035.    if ShipPtr1^.SType=27 then s:=PathStr[7]+'ST/Borg.RAW';
  6036.    if not LOADSAMPLE(s,2) then exit;
  6037.    BSFSoundMemA[3]:=BSFSoundMemA[2]+BSFSoundSize[2]*2;
  6038.    INITSOUNDNAMES(ShipPtr2^.Weapon);
  6039.    if ShipPtr2^.SType=27 then s:=PathStr[7]+'ST/Borg.RAW';
  6040.    if not LOADSAMPLE(s,3) then exit;
  6041.    BSFSoundMemA[4]:=BSFSoundMemA[3]+BSFSoundSize[3]*2;
  6042.    s:=PathStr[7]+'FightSoundDS.RAW';                      { SFX/ }
  6043.    if not LOADSAMPLE(s,4) then exit;
  6044.    BSFSoundSize[4]:=BSFSoundSize[4] div 2;
  6045.  
  6046.    INITIMAGES:=true;
  6047. end;
  6048.  
  6049.  
  6050.  
  6051. procedure XTRAROUND;
  6052.  
  6053. const STARS=15;
  6054.  
  6055. type SArr15=array [0..15] of short;
  6056.  
  6057. var x,y                         :array [0..1] of word;
  6058. var Angle                       :array [0..1] of integer;
  6059. var sx1,sy1,sx2,sy2             :array [0..1,1..2] of integer;
  6060. var StepCtr                     :word;
  6061. var StarX,StarY                 :array [1..STARS] of word;
  6062. var dx,dy,da,FireFactor         :integer;
  6063. var mx,my                       :SArr15;
  6064. var NowDie,Rotation             :byte;
  6065.  
  6066.  
  6067. procedure STARFLY(Ship :byte);
  6068.  
  6069. var i   :byte;
  6070.  
  6071. begin
  6072.    Rotation:=Rotation+1;
  6073.    if Rotation>2 then Rotation:=0;
  6074.    RectFill(^MyScreen[AScr]^.RastPort,x[Ship]-4,y[Ship]-4,x[Ship]+36,y[Ship]+36);
  6075.    case Angle[Ship] of
  6076.         0: y[Ship]:=y[Ship]-2;
  6077.        32: begin
  6078.               x[Ship]:=x[Ship]+1; y[Ship]:=y[Ship]-2;
  6079.            end;
  6080.        64: begin
  6081.               x[Ship]:=x[Ship]+2; y[Ship]:=y[Ship]-2;
  6082.            end;
  6083.        96: begin
  6084.               x[Ship]:=x[Ship]+2; y[Ship]:=y[Ship]-1;
  6085.            end;
  6086.       128: x[Ship]:=x[Ship]+2;
  6087.       160: begin
  6088.               x[Ship]:=x[Ship]+2;  y[Ship]:=y[Ship]+1;
  6089.            end;
  6090.       192: begin
  6091.               x[Ship]:=x[Ship]+2;  y[Ship]:=y[Ship]+2;
  6092.            end;
  6093.       224: begin
  6094.               x[Ship]:=x[Ship]+1;  y[Ship]:=y[Ship]+2;
  6095.            end;
  6096.       256: y[Ship]:=y[Ship]+2;
  6097.       288: begin
  6098.               x[Ship]:=x[Ship]-1;   y[Ship]:=y[Ship]+2;
  6099.            end;
  6100.       320: begin
  6101.               x[Ship]:=x[Ship]-2;   y[Ship]:=y[Ship]+2;
  6102.            end;
  6103.       352: begin
  6104.               x[Ship]:=x[Ship]-2;   y[Ship]:=y[Ship]+1;
  6105.            end;
  6106.       384: x[Ship]:=x[Ship]-2;
  6107.       416: begin
  6108.               x[Ship]:=x[Ship]-2; y[Ship]:=y[Ship]-1;
  6109.            end;
  6110.       448: begin
  6111.               x[Ship]:=x[Ship]-2; y[Ship]:=y[Ship]-2;
  6112.            end;
  6113.       480: begin
  6114.               x[Ship]:=x[Ship]-1; y[Ship]:=y[Ship]-2;
  6115.            end;
  6116.       otherwise;
  6117.    end;
  6118.  
  6119.    dx:=(x[1-Ship]-x[Ship]);
  6120.    dy:=(y[1-Ship]-y[Ship]);
  6121.    if (dx=0) and (dy<0) then da:=0   else
  6122.    if (dx>0) and (dy<0) then da:=64  else
  6123.    if (dx>0) and (dy=0) then da:=128 else
  6124.    if (dx>0) and (dy>0) then da:=192 else
  6125.    if (dx=0) and (dy>0) then da:=256 else
  6126.    if (dx<0) and (dy>0) then da:=320 else
  6127.    if (dx<0) and (dy=0) then da:=384 else
  6128.    if (dx<0) and (dy<0) then da:=448;
  6129.  
  6130.    if Rotation=0 then begin
  6131.       StepCtr:=0;
  6132.       if x[Ship]<15 then StepCtr:=1 else if x[Ship]>592 then StepCtr:=1;
  6133.       if y[Ship]<15 then StepCtr:=StepCtr+1 else if y[Ship]>462 then StepCtr:=StepCtr+1;
  6134.       if StepCtr>1 then Angle[Ship]:=Angle[Ship]+32
  6135.       else if
  6136.        ((y[Ship]<40) and (Angle[Ship] in [0..128]) and (Ship=1)) or
  6137.        ((y[Ship]<90) and (Angle[Ship] in [0..128]) and (Ship=0)) or
  6138.        ((x[Ship]>560) and (Angle[Ship] in [128..256]) and (Ship=1)) or
  6139.        ((x[Ship]>510) and (Angle[Ship] in [128..256]) and (Ship=0)) or
  6140.        ((y[Ship]>420) and (Angle[Ship] in [256..384]) and (Ship=1)) or
  6141.        ((y[Ship]>370) and (Angle[Ship] in [256..384]) and (Ship=0)) or
  6142.        ((x[Ship]<40) and (Angle[Ship] in [384..480,0]) and (Ship=1)) or
  6143.        ((x[Ship]<90) and (Angle[Ship] in [384..480,0]) and (Ship=0)) then Angle[Ship]:=Angle[Ship]+32
  6144.  
  6145.       else if
  6146.        ((y[Ship]<40) and (Angle[Ship] in [384..480]) and (Ship=1)) or
  6147.        ((y[Ship]<90) and (Angle[Ship] in [384..480]) and (Ship=0)) or
  6148.        ((x[Ship]>560) and (Angle[Ship] in [0..96]) and (Ship=1)) or
  6149.        ((x[Ship]>510) and (Angle[Ship] in [0..96]) and (Ship=0)) or
  6150.        ((y[Ship]>420) and (Angle[Ship] in [128..224]) and (Ship=1)) or
  6151.        ((y[Ship]>370) and (Angle[Ship] in [128..224]) and (Ship=0)) or
  6152.        ((x[Ship]<40) and (Angle[Ship] in [256..352]) and (Ship=1)) or
  6153.        ((x[Ship]<90) and (Angle[Ship] in [256..352]) and (Ship=0)) then Angle[Ship]:=Angle[Ship]-32
  6154.  
  6155.       else if
  6156.        (x[Ship] in [x[1-Ship]-130..x[1-Ship]+130]) and (y[Ship] in [y[1-Ship]-130..y[1-Ship]+130])
  6157.         then if Ship=0 then Angle[Ship]:=Angle[Ship]+32 else Angle[Ship]:=Angle[Ship]-32
  6158.  
  6159.       else if (Angle[Ship]<>da) and not (x[Ship] in [2000..440])
  6160.       and not (y[Ship] in [150..350])
  6161.       and not ((x[Ship]<25) or (x[Ship]>582) or (y[Ship]<25) or (y[Ship]>452)) then begin
  6162.          if (da in [Angle[Ship]-224..Angle[Ship]]) or (da-512 in [Angle[Ship]-228..Angle[Ship]]) then
  6163.           Angle[Ship]:=Angle[Ship]-32
  6164.          else Angle[Ship]:=Angle[Ship]+32
  6165.       end;
  6166.       if not (Angle[Ship] in [da-32..da+32]) and (x[Ship] in [50..590]) and (y[Ship] in [50..462]) then case random(20) of
  6167.          0: x[Ship]:=x[Ship]+1;
  6168.          1: x[Ship]:=x[Ship]-1;
  6169.          2: y[Ship]:=y[Ship]+1;
  6170.          3: y[Ship]:=y[Ship]-1;
  6171.          4: Angle[Ship]:=Angle[Ship]+32;
  6172.          5: Angle[Ship]:=Angle[Ship]-32;
  6173.          otherwise;
  6174.       end;
  6175.       while Angle[Ship]<0 do Angle[Ship]:=Angle[Ship]+512;
  6176.       while Angle[Ship]>=512 do Angle[Ship]:=Angle[Ship]-512;
  6177.    end;
  6178.  
  6179.    SetAPen(^MyScreen[AScr]^.RastPort,0);
  6180.    if sx1[Ship,AScr]<>0 then begin
  6181.       Move(^MyScreen[AScr]^.RastPort,sx1[Ship,AScr],sy1[Ship,AScr]);
  6182.       Draw(^MyScreen[AScr]^.RastPort,sx2[Ship,AScr],sy2[Ship,AScr]);
  6183.       sx1[Ship,AScr]:=0;
  6184.    end;
  6185.  
  6186.    BltBitMapRastPort(^ImgBitMap4,Angle[Ship],succ(Ship)*32,^MyScreen[Ascr]^.RastPort,x[Ship],y[Ship],32,32,192);
  6187.  
  6188.    if (Angle[Ship] in [da-32..da+32]) and ((x[Ship] in [x[1-Ship]-150..x[1-Ship]+150]) and (y[Ship] in [y[1-Ship]-150..y[1-Ship]+150])) then begin
  6189.       sx1[Ship,AScr]:=x[Ship]+16;
  6190.       sy1[Ship,AScr]:=y[Ship]+16;
  6191.       FireFactor:=(abs(sx1[Ship,AScr]-x[1-Ship]+16)+abs(sy1[Ship,AScr]-y[1-Ship]+16)) div 3;
  6192.       if FireFactor>75 then FireFactor:=75;
  6193.       sx2[Ship,AScr]:=sx1[Ship,AScr]+ FireFactor*mx[Angle[ship] div 32];
  6194.       sy2[Ship,AScr]:=sy1[Ship,AScr]+ FireFactor*my[Angle[ship] div 32];
  6195.       if (sx2[Ship,AScr]<1) or (sx2[Ship,AScr]>639) or (sy2[Ship,AScr]<1) or (sy2[Ship,AScr]>511) then sx1[Ship,AScr]:=0;
  6196.    end;
  6197.  
  6198.    SPAddrC^:=ZeroSound; SPLengthC^:=1;
  6199.    SPAddrD^:=ZeroSound; SPLengthD^:=1;
  6200. end;
  6201.  
  6202.  
  6203.  
  6204. procedure DRAWFIRE;
  6205.  
  6206. var Ship        :byte;
  6207.  
  6208. begin
  6209.    RECT(MyScreen[AScr]^,7,0,500,639,511);
  6210.    if SSHeader[0].ShieldS>=319 then RECT(MyScreen[AScr]^,14,0,501,319,510)
  6211.    else RECT(MyScreen[AScr]^,14,0,501,SSHeader[0].ShieldS,510);
  6212.    if SSHeader[1].ShieldS>=319 then RECT(MyScreen[AScr]^,15,319,501,639,510)
  6213.    else RECT(MyScreen[AScr]^,15,319,501,SSHeader[1].ShieldS+319,510);
  6214.  
  6215.    for Ship:=0 to 1 do if sx1[Ship,AScr]>0 then begin
  6216.       if Ship=0 then begin
  6217.          DMACON_WRITE^:=$0008;
  6218.          SPAddrD^:=BSFSoundMemA[2]; SPFreqD^:=350; SPLengthD^:=BSFSoundSize[2]; SPVolD^:=50;
  6219.          DMACON_WRITE^:=$8008;
  6220.       end else begin
  6221.          DMACON_WRITE^:=$0004;
  6222.          SPAddrC^:=BSFSoundMemA[3]; SPFreqC^:=300; SPLengthC^:=BSFSoundSize[3]; SPVolC^:=50;
  6223.          DMACON_WRITE^:=$8004;
  6224.       end;
  6225.       if Ship=0 then SetAPen(^MyScreen[AScr]^.RastPort,14) else SetAPen(^MyScreen[AScr]^.RastPort,15);
  6226.       Move(^MyScreen[AScr]^.RastPort,sx1[Ship,AScr],sy1[Ship,AScr]);
  6227.       Draw(^MyScreen[AScr]^.RastPort,sx2[Ship,AScr],sy2[Ship,AScr]);
  6228.       if (sx2[Ship,AScr] in [x[1-Ship]..x[1-Ship]+32]) and (sy2[Ship,AScr] in [y[1-Ship]..y[1-Ship]+32]) then begin
  6229.          SSHeader[1-Ship].ShieldS:=SSHeader[1-Ship].ShieldS-SSHeader[Ship].WeaponS;
  6230.          if Ship=0 then begin
  6231.             DMACON_WRITE^:=$0004;
  6232.             SPAddrC^:=SoundMemA[2]; SPFreqC^:=300; SPLengthC^:=SoundSize[2] div 2; SPVolC^:=64;
  6233.             DMACON_WRITE^:=$8004;
  6234.          end else begin
  6235.             DMACON_WRITE^:=$0008;
  6236.             SPAddrD^:=SoundMemA[2]; SPFreqD^:=350; SPLengthD^:=SoundSize[2] div 2; SPVolD^:=64;
  6237.             DMACON_WRITE^:=$8008;
  6238.          end;
  6239.       end;
  6240.    end;
  6241. end;
  6242.  
  6243.  
  6244.  
  6245. procedure KILLSHIP(Ship,Phase :byte);
  6246.  
  6247. begin
  6248.    if Phase=0 then begin
  6249.       WaitTOF;
  6250.       PLAYSOUND(2,1100);
  6251.       BltBitMapRastPort(^ImgBitMap4,0,0,^MyScreen[AScr]^.RastPort,x[Ship],y[Ship],32,32,192);
  6252.       WaitTOF;
  6253.    end else if Phase=16 then RectFill(^MyScreen[AScr]^.RastPort,x[Ship]-3,y[Ship]-3,x[Ship]+36,y[Ship]+36)
  6254.    else begin
  6255.       RectFill(^MyScreen[AScr]^.RastPort,x[Ship]-3,y[Ship]-3,x[Ship]+36,y[Ship]+36);
  6256.       BltBitMapRastPort(^ImgBitMap4,Phase*32,0,^MyScreen[Ascr]^.RastPort,x[Ship],y[Ship],32,32,192);
  6257.       SPAddrA^:=ZeroSound; SPLengthA^:=1;
  6258.       SPAddrB^:=ZeroSound; SPLengthB^:=1;
  6259.    end;
  6260. end;
  6261.  
  6262.  
  6263.  
  6264. begin
  6265.    Rotation:=0;
  6266.    randomize;
  6267.    for i:=1 to STARS do begin
  6268.       StarX[i]:=succ(random(639 div STARS))*STARS;
  6269.       StarY[i]:=succ(random(505 div STARS))*STARS;
  6270.    end;
  6271.    mx:=SArr15(0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1);
  6272.    my:=SArr15(-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2);
  6273.    sx1[0,1]:=0; sx1[1,1]:=0; sx1[0,2]:=0; sx1[1,2]:=0;
  6274.    x[1]:=520;   y[1]:=100;   Angle[1]:=random(17)*32;
  6275.    x[0]:=120;   y[0]:=412;   Angle[0]:=random(17)*32;
  6276.    StepCtr:=1;
  6277.    RECT(MyScreen[1]^,0,0,0,639,511);
  6278.    RECT(MyScreen[2]^,0,0,0,639,511);
  6279.    DMACON_WRITE^:=$000F;
  6280.    SPAddrA^:=BSFSoundMemA[4]; SPFreqA^:=450; SPLengthA^:=BSFSoundSize[4]; SPVolA^:=40;
  6281.    SPAddrB^:=BSFSoundMemA[4]+BSFSoundSize[4]*2;
  6282.                               SPFreqB^:=450; SPLengthB^:=BSFSoundSize[4]; SPVolB^:=40;
  6283.    DMACON_WRITE^:=$8003;
  6284.    repeat
  6285.       AScr:=3-AScr;
  6286.       SetAPen(^MyScreen[AScr]^.RastPort,12);
  6287.       for i:=1 to STARS do WritePixel(^MyScreen[AScr]^.RastPort,StarX[i],StarY[i]);
  6288.       SetAPen(^MyScreen[AScr]^.RastPort,0);
  6289.       STARFLY(0); STARFLY(1);
  6290.       DRAWFIRE;
  6291.       ScreenToFront(MyScreen[Ascr]);
  6292.    until (SSHeader[0].ShieldS<0) or (SSHeader[1].ShieldS<0);
  6293.    if SSHeader[0].ShieldS<0 then NowDie:=0;
  6294.    if SSHeader[1].ShieldS<0 then NowDie:=1;
  6295.    for i:=1 to 2 do if sx1[NowDie,i]<>0 then begin
  6296.       SetAPen(^MyScreen[i]^.RastPort,0);
  6297.       Move(^MyScreen[i]^.RastPort,sx1[NowDie,i],sy1[NowDie,i]);
  6298.       Draw(^MyScreen[i]^.RastPort,sx2[NowDie,i],sy2[NowDie,i]);
  6299.       sx1[NowDie,i]:=0;
  6300.    end;
  6301.    AScr:=3-AScr;
  6302.    SetAPen(^MyScreen[Ascr]^.RastPort,0);
  6303.    if SSHeader[1-NowDie].ShieldS<=0 then SSheader[1-NowDie].ShieldS:=1;
  6304.    KILLSHIP(NowDie,0);
  6305.    STARFLY(1-NowDie);
  6306.    ScreenToFront(MyScreen[Ascr]);
  6307.    for i:=1 to 16 do for j:=1 to 4 do begin
  6308.       AScr:=3-AScr;
  6309.       SetAPen(^MyScreen[Ascr]^.RastPort,0);
  6310.       KILLSHIP(NowDie,i);
  6311.       STARFLY(1-NowDie);
  6312.       ScreenToFront(MyScreen[Ascr]);
  6313.    end;
  6314.    for i:=1 to 35 do begin
  6315.       AScr:=3-AScr;
  6316.       SetAPen(^MyScreen[AScr]^.RastPort,12);
  6317.       for i:=1 to STARS do WritePixel(^MyScreen[AScr]^.RastPort,StarX[i],StarY[i]);
  6318.       SetAPen(^MyScreen[AScr]^.RastPort,0);
  6319.       STARFLY(1-NowDie);
  6320.       ScreenToFront(MyScreen[Ascr]);
  6321.    end;
  6322.    DMACON_WRITE^:=$000F;
  6323. end;
  6324.  
  6325.  
  6326.  
  6327. function SMALLSHIPFIGHT(ShipPtr1,ShipPtr2,ShipPtr02 :ShipHeader; Mode,ActSys :byte):byte;
  6328.  
  6329. var Shield1,Shield2,Fire1,Fire2 :integer;
  6330.  
  6331. begin
  6332.    Shield1:=ShipPtr1^.Shield+ShipPtr1^.ShieldBonus+MyShipPtr^.Tactical*3;
  6333.    repeat
  6334.       Shield2:=ShipPtr2^.Shield+ShipPtr2^.ShieldBonus+MyShipPtr^.Tactical*3;
  6335.       Fire1:=round((ShipPtr1^.Weapon/10+1)*ShipData[ShipPtr1^.SType].WeaponPower-ShipPtr1^.Tactical);
  6336.       Fire2:=round((ShipPtr2^.Weapon/10+1)*ShipData[ShipPtr2^.SType].WeaponPower-ShipPtr2^.Tactical);
  6337.       randomize;
  6338.       repeat
  6339.          case random(2) of
  6340.             0: Shield1:=Shield1-Fire2;
  6341.             1: Shield2:=Shield2-Fire1;
  6342.          end;
  6343.       until (Shield1<=0) or (Shield2<=0);
  6344.       if Shield1<=0 then begin
  6345.          SMALLSHIPFIGHT:=1;
  6346.          with ShipPtr2^ do begin
  6347.             if Shield2-ShieldBonus-Tactical*3>0 then
  6348.              Shield:=Shield2-ShieldBonus-Tactical*3 else Shield:=1;
  6349.             if ShipPtr1^.SType>SType then ShieldBonus:=ShieldBonus+(ShipPtr1^.SType-SType)
  6350.             else ShieldBonus:=ShieldBonus+1;
  6351.          end;
  6352.          ShipPtr1^.Owner:=0;
  6353.          exit;
  6354.       end else begin
  6355.          SMALLSHIPFIGHT:=2;
  6356.          with ShipPtr1^ do begin
  6357.             if Shield1-ShieldBonus-Tactical*3>0 then
  6358.              Shield:=Shield1-ShieldBonus-Tactical*3 else Shield:=1;
  6359.             if ShipPtr2^.SType>SType then ShieldBonus:=ShieldBonus+(ShipPtr2^.SType-SType)
  6360.             else ShieldBonus:=ShieldBonus+1;
  6361.             PosX:=FromX;
  6362.             PosY:=FromY;
  6363.          end;
  6364.          ShipPtr2^.Owner:=0;
  6365.          if Mode in [MODE_ALL,MODE_FLEET] then begin
  6366.             if not (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0)
  6367.             or (ShipPtr1^.Owner=ActPlayerFlag) or (ShipPtr2^.Owner=ActPlayerFlag) then begin
  6368.                if Mode=MODE_ALL then begin
  6369.                   if Visible then PLAYSOUND(2,900);
  6370.                   delay(20);
  6371.                end else begin
  6372.                   ShipPtr2^.PosX:=ShipPtr02^.PosX;
  6373.                   ShipPtr2^.PosY:=ShipPtr02^.PosY;
  6374.                   if Visible then EXPLODE(ActSys,ShipPtr2);
  6375.                end;
  6376.             end;
  6377.             repeat
  6378.                ShipPtr2:=ShipPtr2^.NextShip
  6379.             until (ShipPtr2^.Owner<>0) or (ShipPtr2=NIL);
  6380.          end;
  6381.       end;
  6382.    until (Mode=MODE_ONCE) or (ShipPtr2=NIL);
  6383. end;
  6384.  
  6385.  
  6386.  
  6387. procedure BIGFIGHTEXIT;
  6388.  
  6389. var b   :boolean;
  6390.  
  6391. begin
  6392.    DoClock:=false;
  6393.    CLOSEMYSCREENS;
  6394.    b:=OPENMAINSCREENS;
  6395.    b:=INITDESK(0);
  6396.    Screen2:=0;
  6397.    if (SSHeader[0].ShieldS>0) and (SSHeader[1].ShieldS>0) then BIGSHIPFIGHT:=SMALLSHIPFIGHT(ShipPtr1,ShipPtr2,NIL,Mode,ActSys);
  6398.    DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  6399.    ScreenToFront(MyScreen[1]);
  6400. end;
  6401.  
  6402.  
  6403.  
  6404. begin
  6405.    ShipPtr1:=Ship1; ShipPtr2:=Ship2;
  6406.    if Ship2^.SType=SHIPTYPE_FLEET then begin
  6407.       ShipPtr2:=Ship2^.TargetShip;
  6408.       Mode:=MODE_FLEET;
  6409.    end;
  6410.    while (ShipPtr2^.Owner=0) and (ShipPtr2<>NIL) do ShipPtr2:=ShipPtr2^.NextShip;
  6411.    if ShipPtr2=NIL then begin
  6412.       BIGSHIPFIGHT:=2;
  6413.       exit;
  6414.    end;
  6415.    if (Save.CivPlayer[GETCIVVAR(ShipPtr1^.Owner)]<>0)
  6416.     or (Save.CivPlayer[GETCIVVAR(ShipPtr2^.Owner)]<>0)
  6417.     or (Display=ActSys) then Visible:=true else Visible:=false;
  6418.    if ((ShipPtr1^.Owner<>ActPlayerFlag) and (ShipPtr2^.Owner<>ActPlayerFlag))
  6419.    or ((Save.CivPlayer[GETCIVVAR(ShipPtr1^.Owner)]=0) and (Save.CivPlayer[GETCIVVAR(ShipPtr2^.Owner)]=0))
  6420.    or (Save.SmallFight) or (Ship2^.SType=SHIPTYPE_FLEET) then begin
  6421.       l:=SMALLSHIPFIGHT(ShipPtr1,ShipPtr2,Ship2,Mode,ActSys);
  6422.       if (l=1) and Visible then EXPLODE(ActSys,ShipPtr1)
  6423.       else if (l=2) and (Mode<>MODE_FLEET) and Visible then EXPLODE(ActSys,ShipPtr2);
  6424.       BIGSHIPFIGHT:=l;
  6425.       if Ship2^.SType=SHIPTYPE_FLEET then begin
  6426.          ShipPtr2:=Ship2^.TargetShip;
  6427.          repeat
  6428.             if ShipPtr2^.Owner=0 then begin
  6429.                Ship2^.TargetShip:=ShipPtr2^.NextShip;
  6430.                if ShipPtr2^.NextShip<>NIL then ShipPtr2^.NextShip^.BeforeShip:=Ship2;
  6431.                LINKSHIP(ShipPtr2,Ship2,0);
  6432.             end;
  6433.             ShipPtr2:=Ship2^.TargetShip;
  6434.          until (ShipPtr2=NIL) or (ShipPtr2^.Owner<>0);
  6435.          if ShipPtr2=NIL then Ship2^.Owner:=0
  6436.          else if ShipPtr2^.NextShip=NIL then begin
  6437.             Ship2^.Owner:=0;
  6438.             Ship2^.SType:=8;
  6439.             ShipPtr2^.PosX:=Ship2^.PosX;
  6440.             ShipPtr2^.PosY:=Ship2^.PosY;
  6441.             LINKSHIP(ShipPtr2,Ship2,0);
  6442.          end;
  6443.          REFRESHDISPLAY;
  6444.       end;
  6445.       exit;
  6446.    end;
  6447.    SSHeader[0].ShieldS:=1;
  6448.    SSHeader[1].ShieldS:=1;
  6449.    CLOSEMYSCREENS;
  6450.    Display:=100;
  6451.    MyScreen[1]:=NIL;         MyScreen[2]:=NIL;
  6452.    NeuScreen:=NewScreen(0,0,640,512,4,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,
  6453.                         NIL,'',NIL,NIL);
  6454.    for i:=1 to 2 do begin
  6455.       MyScreen[i]:=OpenScreenTagList(^NeuScreen,^Tags);
  6456.       if MyScreen[i]<>NIL then begin
  6457.          SetRGB4(^MyScreen[i]^.ViewPort,1,0,0,0);
  6458.          SetRGB4(^MyScreen[i]^.ViewPort,2,13,13,15);  SetRGB4(^MyScreen[i]^.ViewPort,3,12,12,14);
  6459.          SetRGB4(^MyScreen[i]^.ViewPort,4,11,11,13);  SetRGB4(^MyScreen[i]^.ViewPort,5,10,10,12);
  6460.          SetRGB4(^MyScreen[i]^.ViewPort,6,9,9,11);    SetRGB4(^MyScreen[i]^.ViewPort,7,8,8,10);
  6461.          SetRGB4(^MyScreen[i]^.ViewPort,8,15,0,0);    SetRGB4(^MyScreen[i]^.ViewPort,9,7,5,5);
  6462.          SetRGB4(^MyScreen[i]^.ViewPort,10,15,15,0);  SetRGB4(^MyScreen[i]^.ViewPort,11,15,2,12);
  6463.          SetRGB4(^MyScreen[i]^.ViewPort,12,15,15,15); SetRGB4(^MyScreen[i]^.ViewPort,13,1,1,15);
  6464.       end;
  6465.    end;
  6466.    SWITCHDISPLAY;
  6467.    if MyScreen[1]=NIL then begin
  6468.       BIGFIGHTEXIT; exit;
  6469.    end;
  6470.    if MyScreen[2]=NIL then begin
  6471.       BIGFIGHTEXIT; exit;
  6472.    end;
  6473.    AScr:=2;
  6474.    repeat
  6475.       if not INITIMAGES then begin
  6476.          BIGFIGHTEXIT; exit;
  6477.       end;
  6478.       with ShipPtr1^ do SSHeader[0]:=r_SmallShipHeader((Shield+ShieldBonus+Tactical*3)*2,round((Weapon/10+1)*ShipData[SType].WeaponPower-Tactical));
  6479.       with ShipPtr2^ do SSHeader[1]:=r_SmallShipHeader((Shield+ShieldBonus+Tactical*3)*2,round((Weapon/10+1)*ShipData[SType].WeaponPower-Tactical));
  6480.       for i:=1 to 2 do begin
  6481.          case ShipPtr1^.Owner of
  6482.             FLAG_TERRA:  SetRGB32(^MyScreen[i]^.ViewPort,14,$66000000,$66000000,$FF000000);
  6483.             FLAG_KLEGAN: SetRGB32(^MyScreen[i]^.ViewPort,14,$FF000000,        0,        0);
  6484.             FLAG_REMALO: SetRGB32(^MyScreen[i]^.ViewPort,14,        0,$FF000000,$11000000);
  6485.             FLAG_CARDAC: SetRGB32(^MyScreen[i]^.ViewPort,14,$FF000000,$FF000000,        0);
  6486.             FLAG_FERAGI: SetRGB32(^MyScreen[i]^.ViewPort,14,$BA000000,$8B000000,$48000000);
  6487.             FLAG_BAROJA: SetRGB32(^MyScreen[i]^.ViewPort,14,$FF000000,        0,$B0000000);
  6488.             FLAG_VOLKAN: SetRGB32(^MyScreen[i]^.ViewPort,14,$77000000,$77000000,$77000000);
  6489.             FLAG_OTHER:  SetRGB32(^MyScreen[i]^.ViewPort,14,        0,$FF000000,$FF000000);
  6490.             otherwise    SetRGB32(^MyScreen[i]^.ViewPort,14,$FF000000,$FF000000,$FF000000);
  6491.          end;
  6492.       end;
  6493.       for i:=1 to 2 do begin
  6494.          case ShipPtr2^.Owner of
  6495.             FLAG_TERRA:  SetRGB32(^MyScreen[i]^.ViewPort,15,$66000000,$66000000,$FF000000);
  6496.             FLAG_KLEGAN: SetRGB32(^MyScreen[i]^.ViewPort,15,$FF000000,        0,        0);
  6497.             FLAG_REMALO: SetRGB32(^MyScreen[i]^.ViewPort,15,        0,$FF000000,$11000000);
  6498.             FLAG_CARDAC: SetRGB32(^MyScreen[i]^.ViewPort,15,$FF000000,$FF000000,        0);
  6499.             FLAG_FERAGI: SetRGB32(^MyScreen[i]^.ViewPort,15,$BA000000,$8B000000,$48000000);
  6500.             FLAG_BAROJA: SetRGB32(^MyScreen[i]^.ViewPort,15,$FF000000,        0,$B0000000);
  6501.             FLAG_VOLKAN: SetRGB32(^MyScreen[i]^.ViewPort,15,$77000000,$77000000,$77000000);
  6502.             FLAG_OTHER:  SetRGB32(^MyScreen[i]^.ViewPort,15,        0,$FF000000,$FF000000);
  6503.             otherwise    SetRGB32(^MyScreen[i]^.ViewPort,15,$FF000000,$FF000000,$FF000000);
  6504.          end;
  6505.       end;
  6506.       XTRAROUND;
  6507.       if SSHeader[0].ShieldS<0 then begin
  6508.          BIGSHIPFIGHT:=1;
  6509.          with ShipPtr2^ do begin
  6510.             if (SSHeader[1].ShieldS div 2)-ShieldBonus-Tactical*3>0 then
  6511.              Shield:=(SSHeader[1].ShieldS div 2)-ShieldBonus-Tactical*3 else Shield:=1;
  6512.             if ShipPtr1^.SType>SType then ShieldBonus:=ShieldBonus+(ShipPtr1^.SType-SType)
  6513.             else ShieldBonus:=ShieldBonus+1;
  6514.          end;
  6515.          ShipPtr1^.Owner:=0;
  6516.       end else begin
  6517.          BIGSHIPFIGHT:=2;
  6518.          with ShipPtr1^ do begin
  6519.             if (SSHeader[0].ShieldS div 2)-ShieldBonus-Tactical*3>0 then
  6520.              Shield:=(SSHeader[0].ShieldS div 2)-ShieldBonus-Tactical*3 else Shield:=1;
  6521.             if ShipPtr2^.SType>SType then ShieldBonus:=ShieldBonus+(ShipPtr2^.SType-SType)
  6522.             else ShieldBonus:=ShieldBonus+1;
  6523.             PosX:=FromX;
  6524.             PosY:=FromY;
  6525.          end;
  6526.          ShipPtr2^.Owner:=0;
  6527.          if Mode=MODE_ALL then begin
  6528.             repeat
  6529.                ShipPtr2:=ShipPtr2^.NextShip
  6530.             until (ShipPtr2^.Owner<>0) or (ShipPtr2=NIL);
  6531.          end;
  6532.       end;
  6533.    until (Mode=MODE_ONCE) or (ShipPtr2=NIL) or (ShipPtr1^.Owner=0);
  6534.  
  6535.    BIGFIGHTEXIT;
  6536. end;
  6537.  
  6538.  
  6539.  
  6540. procedure DRAWRECT(x,y :long);
  6541.  
  6542. begin
  6543.    if (x in [1..480]) and (y in [1..480]) then BOX(MyScreen[1]^,x,y,x+31,y+31);
  6544.    WritePixel(^MyScreen[1]^.RastPort,575+MyShipPtr^.PosX,62+MyShipPtr^.PosY);
  6545. end;
  6546.  
  6547.  
  6548.  
  6549. function STARTBIGSHIPFIGHT(Ship1,Ship2 :ShipHeader; Mode,ActSys :byte):byte;
  6550.  
  6551. var MyShipPtr   :^r_ShipHeader;
  6552. var Result      :byte;
  6553. var SFight      :boolean;
  6554.  
  6555. begin
  6556.    SFight:=true;
  6557.    if Ship1^.SType=SHIPTYPE_FLEET then begin
  6558.       exchange(SFight,Save.SmallFight);
  6559.       MyShipPtr:=Ship1^.TargetShip;
  6560.       repeat
  6561.          MyShipPtr^.PosX:=Ship1^.PosX;
  6562.          MyShipPtr^.PosY:=Ship1^.PosY;
  6563.          Result:=BIGSHIPFIGHT(MyShipPtr,Ship2,Mode,ActSys);
  6564.          if MyShipPtr^.Owner=0 then begin
  6565.             Ship1^.TargetShip:=MyShipPtr^.NextShip;
  6566.             if MyShipPtr^.NextShip<>NIL then MyShipPtr^.NextShip^.BeforeShip:=Ship1;
  6567.             LINKSHIP(MyShipPtr,Ship1,0);
  6568.          end;
  6569.          MyShipPtr:=Ship1^.TargetShip;
  6570.       until (Result=2) or (MyShipPtr=NIL);
  6571.       if MyShipPtr=NIL then Ship1^.Owner:=0
  6572.       else if MyShipPtr^.NextShip=NIL then begin
  6573.          Ship1^.Owner:=0;
  6574.          Ship1^.SType:=8;
  6575.          LINKSHIP(MyShipPtr,Ship1,0);
  6576.       end;
  6577.       exchange(SFight,Save.SmallFight);
  6578.    end else STARTBIGSHIPFIGHT:=BIGSHIPFIGHT(Ship1,Ship2,Mode,ActSys);
  6579. end;
  6580.  
  6581.  
  6582.  
  6583. function PLANETHANDLING(ActSys :byte; MyShipPtr :ShipHeader):boolean;
  6584.  
  6585. const GADGET_ANGRIFF= 1;
  6586. const GADGET_ORBIT=   2;
  6587. const GADGET_LADEN=   3;
  6588. const GADGET_LANDUNG= 4;
  6589. const GADGET_DIPLOMAT=8;
  6590. const GADGET_ATTACK =16;
  6591.  
  6592.  
  6593. const MAXGADGETS=7;
  6594.  
  6595. var GadSet              :array [1..MAXGADGETS] of byte;
  6596. var GadCnt              :byte;
  6597. var l                   :long;
  6598. var i                   :integer;
  6599. var b,OldCiviPlanet     :boolean;
  6600. var ShipsInOrbit        :byte;
  6601. var LTOut,SOut,FIn      :integer;
  6602. var MyPlanetHeader      :^r_PlanetHeader;
  6603. var ActPProjects        :^ByteArr42;
  6604. var XShipPtr            :^r_ShipHeader;
  6605. var s                   :string;
  6606.  
  6607. procedure DIPLOMACY;
  6608.  
  6609. const OPT_NONE=10;
  6610. const OPT_SYSTEM=20;
  6611. const OPT_TECH=30;
  6612. const OPT_MONEY=40;
  6613. const OPT_WAR=50;
  6614. const OPT_HELP=60;
  6615. const OPT_SHIP=70;
  6616.  
  6617. var OptArr                              :array[1..7] of str;
  6618. var OptID                               :array[1..7] of byte;
  6619. var XSystem,XTech,CivVar,CivFlag,Opts   :byte;
  6620. var XCosts,l                            :long;
  6621. var s                                   :array [1..MAXCIVS] of string[20];
  6622. var s2                                  :string;
  6623.  
  6624.  
  6625. procedure NEGATIVEANSWER;
  6626.  
  6627. var s   :string;
  6628.  
  6629. begin
  6630.    MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  6631.    s:='Die '+GETCIVADJ(ActPlayer)+'n Forderungen';
  6632.    if (ActPlayer=GETCIVVAR(FLAG_FERAGI))
  6633.     or ((ActPlayer=8) and (Save.WorldFlag=WFLAG_JAHADR)) then s:='Die '+GETCIVADJ(ActPlayer)+'Forderungen';
  6634.    WRITE(256,140,ActPlayerFlag,16,MyScreen[1]^,4,s);
  6635.    WRITE(256,165,ActPlayerFlag,16,MyScreen[1]^,4,'wurden zurückgewiesen.');
  6636.    WAITLOOP(false);
  6637.    RECT(MyScreen[1]^,0,85,120,425,200);
  6638.    REFRESHDISPLAY;
  6639. end;
  6640.  
  6641.  
  6642. procedure POSITIVEANSWER;
  6643.  
  6644. var s   :string;
  6645.  
  6646. begin
  6647.    Save.WarState[ActPlayer,CivVar]:=LEVEL_PEACE;
  6648.    Save.WarState[CivVar,ActPlayer]:=LEVEL_PEACE;
  6649.    MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  6650.    s:='Die '+GETCIVADJ(ActPlayer)+'n Bedingungen';
  6651.    if (ActPlayer=GETCIVVAR(FLAG_FERAGI))
  6652.     or ((ActPlayer=8) and (Save.WorldFlag=WFLAG_JAHADR)) then s:='Die '+GETCIVADJ(ActPlayer)+'Forderungen';
  6653.    WRITE(256,140,ActPlayerFlag,16,MyScreen[1]^,4,s);
  6654.    WRITE(256,165,ActPlayerFlag,16,MyScreen[1]^,4,'wurden akzeptiert.');
  6655.    WAITLOOP(false);
  6656.    RECT(MyScreen[1]^,0,85,120,425,200);
  6657.    REFRESHDISPLAY;
  6658. end;
  6659.  
  6660.  
  6661. function GETOPTION:byte;
  6662.  
  6663. var Pos,i       :byte;
  6664.  
  6665. begin
  6666.    MAKEBORDER(MyScreen[1]^,50,100,460,240,12,6,0);
  6667.    for i:=1 to Opts do  WRITE(60,i*20+90,12,0,MyScreen[1]^,4,OptArr[i]);
  6668.    Pos:=1;
  6669.    repeat
  6670.       delay(RDELAY);
  6671.       if IBase^.MouseY in [110..(90+succ(Opts)*20)] then begin
  6672.          i:=(IBase^.MouseY-90) div 20;
  6673.          if (i<>Pos) and (i in [1..Opts]) then begin
  6674.             Pos:=i;
  6675.             for i:=1 to Opts do if i=Pos then
  6676.              WRITE(60,i*20+90,CivFlag,0,MyScreen[1]^,4,OptArr[i])
  6677.             else WRITE(60,i*20+90,12,0,MyScreen[1]^,4,OptArr[i])
  6678.          end;
  6679.       end;
  6680.    until (LData^ and 64=0) or (RData^ and 1024=0);
  6681.    if (RData^ and 1024)=0 then Pos:=0;
  6682.    PLAYSOUND(1,300);
  6683.    GETOPTION:=Pos;
  6684.    RECT(MyScreen[1]^,0,50,100,460,240);
  6685.    REFRESHDISPLAY;
  6686. end;
  6687.  
  6688.  
  6689.  
  6690. function SMALLREQUEST(s :str):boolean;
  6691.  
  6692. var s2  :string;
  6693.  
  6694. begin
  6695.    MAKEBORDER(MyScreen[1]^,35,110,475,220,12,6,0);
  6696.    s2:='Spieler '+intstr(Save.CivPlayer[CivVar])+', sind sie bereit,';
  6697.    WRITE(256,130,CivFlag,16,MyScreen[1]^,4,s2);
  6698.    WRITE(256,155,CivFlag,16,MyScreen[1]^,4,s);
  6699.    DrawImage(^MyScreen[1]^.RastPort,^GadImg1,55,190);
  6700.    DrawImage(^MyScreen[1]^.RastPort,^GadImg1,337,190);
  6701.    WRITE(115,192,8,16,MyScreen[1]^,4,'Annehmen');
  6702.    WRITE(397,192,8,16,MyScreen[1]^,4,'Ablehnen');
  6703.    repeat
  6704.       delay(RDELAY);
  6705.    until (LData^ and 64=0) and (IBase^.MouseX in [55..183,337..465])
  6706.      and (IBase^.MouseY in [190..210]);
  6707.    if IBase^.MouseX in [55..183] then begin
  6708.       KLICKGAD(55,190);
  6709.       SMALLREQUEST:=true;
  6710.    end else begin
  6711.       KLICKGAD(337,190);
  6712.       SMALLREQUEST:=false;
  6713.    end;
  6714.    RECT(MyScreen[1]^,0,35,110,475,220);
  6715.    REFRESHDISPLAY;
  6716. end;
  6717.  
  6718.  
  6719.  
  6720. procedure CALLOTHERPLAYER;
  6721.  
  6722. begin
  6723.    PLAYERJINGLE(CivVar);
  6724.    MAKEBORDER(MyScreen[1]^,35,80,475,290,12,6,0);
  6725.    WRITE(256,95,12,16,MyScreen[1]^,4,'Friedensverhandlungen');
  6726.    WRITE(256,125,12,16,MyScreen[1]^,4,'-');
  6727.    s2:=GETCIVNAME(ActPlayer); WRITE(160,125,ActPlayerFlag,16,MyScreen[1]^,4,s2);
  6728.    s2:=GETCIVNAME(CivVar);    WRITE(351,125,CivFlag,16,MyScreen[1]^,4,s2);
  6729.    DISPLAYLOGO(ActPlayer,96,150);
  6730.    DISPLAYLOGO(CivVar,287,150);
  6731.    WAITLOOP(false);
  6732.    RECT(MyScreen[1]^,0,35,80,475,290);
  6733.    REFRESHDISPLAY;
  6734. end;
  6735.  
  6736.  
  6737.  
  6738. begin
  6739.    CivFlag:=MyPlanetHeader^.PFlags and FLAG_CIV_MASK;
  6740.    CivVar:=GETCIVVAR(CivFlag);
  6741.    XSystem:=0;
  6742.    for i:=1 to Save.SYSTEMS do
  6743.     if (SystemFlags[CivVar,i] and FLAG_CIV_MASK=CivFlag)
  6744.     and (SystemHeader[i].SysOwner<>CivFlag) then XSystem:=i;
  6745.    XTech:=0;
  6746.    for i:=42 downto 1 do if (Save.TechCosts[ActPlayer,i]>0) and (Save.TechCosts[CivVar,i]<=0) then XTech:=i;
  6747.    XCosts:=abs(Year) * 43;
  6748.    if (XCosts>Save.Staatstopf[CivVar]) then XCosts:=Save.Staatstopf[CivVar];
  6749.    Opts:=1;
  6750.    if Save.WarState[ActPlayer,CivVar]=LEVEL_WAR then begin
  6751.       OptArr[Opts]:='Frieden ohne Bedingungen';
  6752.       OptID[Opts]:=OPT_NONE;
  6753.       Opts:=2;
  6754.       if XSystem>0 then begin
  6755.          OptArr[Opts]:='Frieden gegen Sonnensystem';
  6756.          OptID[Opts]:=OPT_SYSTEM;
  6757.          Opts:=Opts+1;
  6758.       end;
  6759.       if XTech>0 then begin
  6760.          OptArr[Opts]:='Frieden gegen Technologie';
  6761.          OptID[Opts]:=OPT_TECH;
  6762.          Opts:=Opts+1;
  6763.       end;
  6764.       OptArr[Opts]:='Frieden gegen Reparationen';
  6765.       OptID[Opts]:=OPT_MONEY;
  6766.       Opts:=Opts+1;
  6767.    end else begin
  6768.       if XSystem>0 then begin
  6769.          OptArr[Opts]:='Sonnensystem für Frieden';
  6770.          OptID[Opts]:=OPT_SYSTEM;
  6771.          Opts:=Opts+1;
  6772.       end;
  6773.       if XTech>0 then begin
  6774.          OptArr[Opts]:='Technologie für Frieden';
  6775.          OptID[Opts]:=OPT_TECH;
  6776.          Opts:=Opts+1;
  6777.       end;
  6778.       OptArr[Opts]:='Tributzahlungen für Frieden';
  6779.       OptID[Opts]:=OPT_MONEY;
  6780.       Opts:=Opts+1;
  6781.       OptArr[Opts]:='Gemeinsamen Feldzug anbieten';
  6782.       OptID[Opts]:=OPT_WAR;
  6783.       Opts:=Opts+1;
  6784.       if Save.CivPlayer[CivVar]=0 then begin
  6785.          OptArr[Opts]:='Entwicklungshilfe leisten';
  6786.          OptID[Opts]:=OPT_HELP;
  6787.          Opts:=Opts+1;
  6788.          if Save.WarPower[CivVar]<Save.WarPower[ActPlayer] then begin
  6789.             OptArr[Opts]:='Schiff übergeben';
  6790.             OptID[Opts]:=OPT_SHIP;
  6791.             Opts:=Opts+1;
  6792.          end;
  6793.       end;
  6794.    end;
  6795.    Opts:=Opts-1;
  6796.    l:=GETOPTION;
  6797.    if l=0 then exit;
  6798.    if (CivVar=8) and (Save.WorldFlag=WFLAG_JAHADR) and (OptID[l]<>OPT_HELP)
  6799.     then OptID[l]:=OPT_NONE;
  6800.    if (Save.CivPlayer[CivVar]<>0) and not Save.PlayMySelf then begin
  6801.       if OptID[l]<>OPT_WAR then CALLOTHERPLAYER;
  6802.       case OptID[l] of
  6803.          OPT_NONE:   begin
  6804.                         if SMALLREQUEST('einen bedingungslosen Frieden zu akzeptieren?')
  6805.                         then POSITIVEANSWER else NEGATIVEANSWER;
  6806.                      end;
  6807.          OPT_SYSTEM: begin
  6808.                         s2:='das System '+Save.SystemName[XSystem]+' zu übergeben?';
  6809.                         SYSINFO(XSystem,CivFlag);
  6810.                         if not SMALLREQUEST(s2) then NEGATIVEANSWER else begin
  6811.                            POSITIVEANSWER;
  6812.                            SYSTEMTOENEMY(XSystem,ActPlayerFlag,CivFlag);
  6813.                         end;
  6814.                         RECT(MyScreen[1]^,0,30,250,480,360);
  6815.                      end;
  6816.          OPT_TECH:   begin
  6817.                         s2:='Informationen über '+Technology[XTech]+' zu übergeben?';
  6818.                         if not SMALLREQUEST(s2) then NEGATIVEANSWER else begin
  6819.                            POSITIVEANSWER;
  6820.                            Save.TechCosts[ActPlayer,XTech]:=0;
  6821.                            DISPLAYTECH(XTech,ActPlayer);
  6822.                         end;
  6823.                      end;
  6824.          OPT_MONEY:  begin
  6825.                         s2:=intstr(XCosts)+' an Reparationen zu zahlen?';
  6826.                         if not SMALLREQUEST(s2) then NEGATIVEANSWER else begin
  6827.                            POSITIVEANSWER;
  6828.                            Save.Staatstopf[CivVar]:=Save.StaatsTopf[CivVar]-XCosts;
  6829.                            Save.Staatstopf[ActPlayer]:=Save.StaatsTopf[ActPlayer]+XCosts;
  6830.                            PRINTGLOBALINFOS(ActPlayer);
  6831.                         end;
  6832.                      end;
  6833.          OPT_WAR:    begin
  6834.                         Opts:=1;
  6835.                         for i:=1 to pred(MAXCIVS) do if not (i in [CivVar,ActPlayer])
  6836.                         and not (Save.WarState[ActPlayer,i] in [LEVEL_DIED,LEVEL_UNKNOWN])
  6837.                         and ((i<8) or (Save.WorldFlag<>0)) then begin
  6838.                            s[i]:='gegen '+GETCIVNAME(i);
  6839.                            OptArr[Opts]:=s[i];
  6840.                            OptID[Opts]:=i;
  6841.                            Opts:=Opts+1;
  6842.                         end;
  6843.                         Opts:=Opts-1;
  6844.                         if Opts>0 then begin
  6845.                            l:=GETOPTION;
  6846.                            if l=0 then exit;
  6847.                            CALLOTHERPLAYER;
  6848.                            s2:='Krieg gegen die '+GETCIVNAME(OptID[l])+' zu führen?';
  6849.                            if not SMALLREQUEST(s2) then NEGATIVEANSWER else begin
  6850.                               POSITIVEANSWER;
  6851.                               GOTOWAR(ActPlayerFlag,GETCIVFLAG(OptID[l]));
  6852.                               GOTOWAR(CivFlag,GETCIVFLAG(OptID[l]));
  6853.                               Save.WarState[ActPlayer,CivVar]:=LEVEL_ALLIANZ;
  6854.                               Save.WarState[CivVar,ActPlayer]:=LEVEL_ALLIANZ;
  6855.                            end;
  6856.                         end else begin
  6857.                            MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  6858.                            WRITE(256,140,12,16,MyScreen[1]^,4,'Keine weiteren');
  6859.                            WRITE(256,160,12,16,MyScreen[1]^,4,'Zivilisationen bekannt.');
  6860.                            WAITLOOP(false);
  6861.                            RECT(MyScreen[1]^,0,85,120,425,200);
  6862.                            REFRESHDISPLAY;
  6863.                         end;
  6864.                      end;
  6865.  
  6866.          otherwise;
  6867.       end;
  6868.       exit;
  6869.    end;
  6870.    case OptID[l] of
  6871.       OPT_NONE:   VERHANDLUNG(CivFlag,MODE_FORCE);
  6872.       OPT_SYSTEM: if (Save.WarPower[CivVar]*4>Save.WarPower[ActPlayer]) or (XSystem=0) then NEGATIVEANSWER
  6873.                   else if random(2)=0 then begin
  6874.                      POSITIVEANSWER;
  6875.                      SYSTEMTOENEMY(XSystem,ActPlayerFlag,CivFlag);
  6876.                      if (Save.WorldFlag=ActPlayerFlag) and (CivVar=8) then STOPCIVILWAR(0);
  6877.                   end else VERHANDLUNG(CivFlag,MODE_OFFENSIV);
  6878.       OPT_TECH:   if (Save.WarPower[CivVar]*3>Save.WarPower[ActPlayer]) or (XTech=0) then NEGATIVEANSWER
  6879.                   else if random(3)<>0 then begin
  6880.                      POSITIVEANSWER;
  6881.                      Save.TechCosts[ActPlayer,XTech]:=0;
  6882.                      DISPLAYTECH(XTech,ActPlayer);
  6883.                      if (Save.WorldFlag=ActPlayerFlag) and (CivVar=8) then STOPCIVILWAR(0);
  6884.                   end else VERHANDLUNG(CivFlag,MODE_OFFENSIV);
  6885.       OPT_MONEY:  if (Save.WarPower[CivVar]*2>Save.WarPower[ActPlayer]) or (XCosts<10000) then NEGATIVEANSWER
  6886.                   else if random(3)<>0 then begin
  6887.                      Save.WarState[ActPlayer,CivVar]:=LEVEL_PEACE;
  6888.                      Save.WarState[CivVar,ActPlayer]:=LEVEL_PEACE;
  6889.                      Save.Staatstopf[CivVar]:=Save.StaatsTopf[CivVar]-XCosts;
  6890.                      Save.Staatstopf[ActPlayer]:=Save.StaatsTopf[ActPlayer]+XCosts;
  6891.                      MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  6892.                      WRITE(256,127,ActPlayerFlag,16,MyScreen[1]^,4,'Sie erhalten Reparationen');
  6893.                      WRITE(256,147,ActPlayerFlag,16,MyScreen[1]^,4,'in Höhe von');
  6894.                      s[1]:=intstr(XCosts);
  6895.                      WRITE(256,173,CivFlag,16,MyScreen[1]^,4,s[1]);
  6896.                      WAITLOOP(false);
  6897.                      RECT(MyScreen[1]^,0,85,120,425,200);
  6898.                      if (Save.WorldFlag=ActPlayerFlag) and (CivVar=8) then STOPCIVILWAR(0);
  6899.                   end else VERHANDLUNG(CivFlag,MODE_OFFENSIV);
  6900.       OPT_WAR:    begin
  6901.                      Opts:=1;
  6902.                      for i:=1 to pred(MAXCIVS) do if not (i in [CivVar,ActPlayer])
  6903.                      and not (Save.WarState[ActPlayer,i] in [LEVEL_DIED,LEVEL_UNKNOWN])
  6904.                      and ((i<8) or (Save.WorldFlag<>0)) then begin
  6905.                         s[i]:='gegen '+GETCIVNAME(i);
  6906.                         OptArr[Opts]:=s[i];
  6907.                         OptID[Opts]:=i;
  6908.                         Opts:=Opts+1;
  6909.                      end;
  6910.                      Opts:=Opts-1;
  6911.                      if Opts>0 then begin
  6912.                         l:=GETOPTION;
  6913.                         if l=0 then exit;
  6914.                         if ((CivVar in [2..4]) and (Save.WarPower[CivVar]>80)) or
  6915.                          ((Save.GlobalFlags[CivVar]=GFLAG_ATTACK) and (Save.WarPower[ActPlayer]+Save.WarPower[OptID[l]]>Save.WarPower[CivVar]))
  6916.                          or (Save.WarState[CivVar,OptID[l]]=LEVEL_WAR) then begin
  6917.                             POSITIVEANSWER;
  6918.                             GOTOWAR(ActPlayerFlag,GETCIVFLAG(OptID[l]));
  6919.                             GOTOWAR(CivFlag,GETCIVFLAG(OptID[l]));
  6920.                             if (CivVar<>8) and (ActPlayer<>8) then begin
  6921.                                Save.WarState[ActPlayer,CivVar]:=LEVEL_ALLIANZ;
  6922.                                Save.WarState[CivVar,ActPlayer]:=LEVEL_ALLIANZ;
  6923.                             end;
  6924.                          end else NEGATIVEANSWER;
  6925.                      end else begin
  6926.                         MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  6927.                         WRITE(256,140,12,16,MyScreen[1]^,4,'Keine weiteren');
  6928.                         WRITE(256,160,12,16,MyScreen[1]^,4,'Zivilisationen bekannt.');
  6929.                         WAITLOOP(false);
  6930.                         RECT(MyScreen[1]^,0,85,120,425,200);
  6931.                         REFRESHDISPLAY;
  6932.                      end;
  6933.                   end;
  6934.       OPT_HELP:   begin
  6935.                      i:=random(3);
  6936.                      if i in [0,1] then begin
  6937.                         XTech:=0;
  6938.                         for i:=40 downto 1 do
  6939.                          if (Save.TechCosts[ActPlayer,i]<=0) and (Save.TechCosts[CivVar,i]>0)
  6940.                          then XTech:=i;
  6941.                         if XTech=0 then i:=2 else begin
  6942.                            i:=0;
  6943.                            s2:=Technology[XTech]+'.';
  6944.                            REQUEST('Sie übergeben Informationen über',s2,ActPlayerFlag,ActPlayerFlag);
  6945.                            Save.TechCosts[CivVar,XTech]:=0;
  6946.                            Save.WarState[CivVar,ActPlayer]:=LEVEL_ALLIANZ;
  6947.                            Save.WarState[ActPlayer,CivVar]:=LEVEL_ALLIANZ;
  6948.                         end;
  6949.                      end;
  6950.                      if i=2 then begin
  6951.                         XCosts:=abs(Year)*27;
  6952.                         if XCosts>Save.Staatstopf[ActPlayer] div 5
  6953.                          then XCosts:=Save.Staatstopf[ActPlayer] div 5;
  6954.                         if XCosts=0 then i:=3 else begin
  6955.                            i:=0;
  6956.                            s2:='von '+intstr(XCosts)+'.';
  6957.                            REQUEST('Sie zahlen Beihilfen in Höhe',s2,ActPlayerFlag,ActPlayerFlag);
  6958.                            Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]+XCosts;
  6959.                            Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-XCosts;
  6960.                            Save.WarState[CivVar,ActPlayer]:=LEVEL_ALLIANZ;
  6961.                            Save.WarState[ActPlayer,CivVar]:=LEVEL_ALLIANZ;
  6962.                            PRINTGLOBALINFOS(ActPlayer);
  6963.                         end;
  6964.                      end;
  6965.                      if i=3 then REQUEST('Leider haben sie nichts, was','diese Zivilisation gebrauchen könnte!',ActPlayerFlag,ActPlayerFlag);
  6966.                      RECT(MyScreen[1]^,0,85,120,425,200);
  6967.                      REFRESHDISPLAY;
  6968.                   end;
  6969.       OPT_SHIP:   begin
  6970.                      if MyShipPtr^.SType=SHIPTYPE_FLEET then PLAYSOUND(1,600) else begin
  6971.                         MyShipPtr^.Owner:=CivFlag;
  6972.                         MyShipPtr^.Moving:=0;
  6973.                      end;
  6974.                      RECT(MyScreen[1]^,0,85,120,425,200);
  6975.                      REFRESHDISPLAY;
  6976.                      delay(15);
  6977.                   end;
  6978.       otherwise;
  6979.    end;
  6980. end;
  6981.  
  6982.  
  6983.  
  6984. procedure MAKELOADWINDOW;
  6985.  
  6986. begin
  6987.    MAKEBORDER(MyScreen[1]^,42,148,469,273,12,6,0);
  6988.    BltBitMapRastPort(^ImgBitMap4,(MyShipPtr^.SType-8)*32,32,^MyScreen[1]^.RastPort,59,163,32,32,192);
  6989.    BltBitMapRastPort(^ImgBitMap7,MyPlanetHeader^.Class*32,0,^MyScreen[1]^.RastPort,59,227,32,32,192);
  6990.    for i:=1 to 3 do MAKEBORDER(MyScreen[1]^,i*115-3,163,i*115+97,193,12,6,1);
  6991.    with MyPlanetHeader^ do begin
  6992.       if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) or (Population=0) then MAKEBORDER(MyScreen[1]^,112,228,212,258,12,6,1);
  6993.       if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) or (Population>0) then MAKEBORDER(MyScreen[1]^,227,228,327,258,12,6,1);
  6994.       if ((PFlags and FLAG_CIV_MASK in [ActPlayerFlag,0]) or (ActPProjects^[34]=0) and (ActPProjects^[40]=0)
  6995.       or (ProjectPtr=NIL)) and (Class<>CLASS_STONES) then MAKEBORDER(MyScreen[1]^,342,228,442,258,12,6,1);
  6996.    end;
  6997.    WRITE(133,203,ActPlayerFlag,0,MyScreen[1]^,4,'Siedler');
  6998.    WRITE(232,203,ActPlayerFlag,0,MyScreen[1]^,4,'Landungstr.');
  6999.    WRITE(363,203,ActPlayerFlag,0,MyScreen[1]^,4,'Wasser.');
  7000. end;
  7001.  
  7002.  
  7003. procedure WRITELOADDATA;
  7004.  
  7005.  
  7006. procedure CLIPPLANET(Class :byte);
  7007.  
  7008. begin
  7009.    BltBitMapRastPort(^ImgBitMap7,Class*32,0,^MyScreen[1]^.RastPort,59,227,32,32,192);
  7010. end;
  7011.  
  7012.  
  7013. begin
  7014.    with MyShipPtr^ do begin
  7015.       s:=intstr(ShipData[SType].MaxLoad);        while length(s)<2 do s:='0'+s;
  7016.       s:=intstr((Ladung and MASK_SIEDLER) div 16)+' '+s;  while length(s)<5 do s:='0'+s;
  7017.       WRITE(128,171,8,1,MyScreen[1]^,2,s);
  7018.  
  7019.       s:=intstr(ShipData[SType].MaxLoad); while length(s)<2 do s:='0'+s;
  7020.       s:=intstr(Ladung and MASK_LTRUPPS)+' '+s;    while length(s)<5 do s:='0'+s;
  7021.       WRITE(243,171,8,1,MyScreen[1]^,2,s);
  7022.  
  7023.       s:=intstr(round(Fracht/ShipData[SType].MaxLoad*100))+'%';
  7024.       while length(s)<4 do s:='0'+s;
  7025.       WRITE(364,171,8,1,MyScreen[1]^,2,s);
  7026.  
  7027.       with MyPlanetHeader^ do begin
  7028.          if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) or (Population=0) then begin
  7029.             s:=intstr(ActPProjects^[26]);   while length(s)<3 do s:='0'+s;
  7030.             WRITE(141,236,8,1,MyScreen[1]^,2,s);
  7031.          end;
  7032.          if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) or (Population>0) then begin
  7033.             if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) then s:=intstr(ActPProjects^[27])
  7034.             else if Population>0 then s:=intstr(LTOut);
  7035.             while length(s)<3 do s:='0'+s;
  7036.             WRITE(256,236,8,1,MyScreen[1]^,2,s);
  7037.          end;
  7038.          if ((PFlags and FLAG_CIV_MASK in [ActPlayerFlag,0]) or ((ActPProjects^[34]=0) and (ActPProjects^[40]=0))
  7039.          or (ProjectPtr=NIL)) and (Class<>CLASS_STONES) then begin
  7040.             s:=intstr(Water div Size)+'%';   while length(s)<4 do s:='0'+s;
  7041.             WRITE(353,236,8,1,MyScreen[1]^,2,s);
  7042.             if (Water div Size>80) then begin
  7043.                if Class=CLASS_ICE then begin
  7044.                   s:=' I  ';
  7045.                   CLIPPLANET(CLASS_ICE);
  7046.                end else begin
  7047.                   s:='W';
  7048.                   CLIPPLANET(CLASS_WATER);
  7049.                end;
  7050.             end else if (Water div Size in [55..80]) then begin
  7051.                s:='M';
  7052.                CLIPPLANET(CLASS_EARTH);
  7053.             end else if (Water div Size in [21..54]) then begin
  7054.                s:='H ';
  7055.                CLIPPLANET(CLASS_HALFEARTH);
  7056.             end else if (Water div Size<21) then begin
  7057.                s:='D ';
  7058.                CLIPPLANET(CLASS_DESERT);
  7059.             end;
  7060.             WRITE(419,235,ActPlayerFlag,1,MyScreen[1]^,4,s);
  7061.          end;
  7062.       end;
  7063.    end;
  7064. end;
  7065.  
  7066.  
  7067.  
  7068. begin
  7069.    PLANETHANDLING:=false;
  7070.    MyPlanetHeader:=ObjPtr;
  7071.    CivVar:=GETCIVVAR(MyPlanetHeader^.PFlags);
  7072.    if CivVar=0 then MyPlanetHeader^.Population:=0;
  7073.    ActPProjects:=MyPlanetHeader^.ProjectPtr;
  7074.    MyShipPtr^.PosX:=FromX;
  7075.    MyShipPtr^.PosY:=FromY;
  7076.    GadCnt:=1;
  7077.    for i:=1 to MAXGADGETS do GadSet[i]:=0;
  7078.    with MyPlanetHeader^ do begin
  7079.       ShipsInOrbit:=0;
  7080.       if FirstShip.NextShip<>NIL then begin
  7081.          XShipPtr:=FirstShip.NextShip;
  7082.          repeat
  7083.             ShipsInOrbit:=XShipPtr^.Owner;
  7084.             XShipPtr:=XShipPtr^.NextShip;
  7085.          until (ShipsInOrbit<>0) or (XShipPtr=NIL);
  7086.       end;
  7087.       l:=PFlags and FLAG_CIV_MASK;
  7088.       if not (l in [0,ActPlayerFlag]) then begin
  7089.          GadSet[1]:=GADGET_DIPLOMAT;
  7090.          GadCnt:=2;
  7091.       end;
  7092.       if not (l in [0,ActPlayerFlag]) and (ShipsInOrbit<>0) then begin
  7093.          GadSet[GadCnt]:=GADGET_ATTACK;
  7094.          GadCnt:=GadCnt+1;
  7095.       end;
  7096.       if (l in [0,ActPlayerFlag]) then
  7097.        if ShipsInOrbit in [0,ActPlayerFlag] then begin
  7098.          GadSet[GadCnt]:=GADGET_ORBIT;
  7099.          GadCnt:=GadCnt+1;
  7100.       end;
  7101.       if MyShipPtr^.SType<>SHIPTYPE_FLEET then begin
  7102.          if (Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,CLASS_ICE,
  7103.          CLASS_STONES,CLASS_WATER]) and
  7104.          (((ShipsInOrbit in [0,ActPlayerFlag]) and (ActPProjects^[34]=0) and (ActPProjects^[40]=0))
  7105.          or (ProjectPtr=NIL) or (l=ActPlayerFlag)) then begin
  7106.             GadSet[GadCnt]:=GADGET_LADEN;
  7107.             GadCnt:=GadCnt+1;
  7108.          end;
  7109.          if (Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,CLASS_ICE,CLASS_STONES,
  7110.          CLASS_WATER]) and ((ProjectPtr=NIL) or (l<>0) or (ActPProjects^[34]<>0)
  7111.          or (ActPProjects^[40]<>0)) and ((l=ActPlayerFlag) or (ShipsInOrbit=0)) then begin
  7112.             GadSet[GadCnt]:=GADGET_ANGRIFF;
  7113.             GadCnt:=GadCnt+1;
  7114.          end;
  7115.          if not (l<>ActPlayerFlag) and (ShipsInOrbit=0)
  7116.          and (((ActPProjects^[34]=0) and (ActPProjects^[40]=0))
  7117.          or (ProjectPtr=NIL)) then begin
  7118.             GadSet[GadCnt]:=GADGET_LANDUNG;
  7119.             GadCnt:=GadCnt+1;
  7120.          end;
  7121.       end;
  7122.       GadCnt:=GadCnt-1;
  7123.       MAKEBORDER(MyScreen[1]^,194,119,316,122+GadCnt*22,12,6,1);
  7124.       for i:=1 to GadCnt do begin
  7125.          DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  7126.          case GadSet[i] of
  7127.             GADGET_LADEN:    WRITE(256,103+i*22,0,16,MyScreen[1]^,4,'Be-/Entladen');
  7128.             GADGET_ORBIT:    WRITE(256,103+i*22,0,16,MyScreen[1]^,4,'Orbit');
  7129.             GADGET_LANDUNG:  WRITE(256,103+i*22,0,16,MyScreen[1]^,4,'Einnehmen');
  7130.             GADGET_DIPLOMAT: WRITE(256,103+i*22,0,16,MyScreen[1]^,4,'Verhandeln');
  7131.             otherwise WRITE(256,102+i*22,0,16,MyScreen[1]^,4,'Angriff');
  7132.          end;
  7133.       end;
  7134.       b:=false;
  7135.       LTOut:=0; SOut:=0; FIn:=0;
  7136.       repeat
  7137.          delay(RDELAY);
  7138.          if (LData^ and 64=0) then begin
  7139.             if (IBase^.MouseX in [198..315]) and (IBase^.MouseY in [122..pred((100+succ(GadCnt)*22))]) then begin
  7140.                l:=(IBase^.MouseY-100) div 22;
  7141.                KLICKGAD(198,100+l*22);
  7142.                RECT(MyScreen[1]^,0,194,119,316,122+GadCnt*22);
  7143.                REFRESHDISPLAY;
  7144.                case GadSet[l] of
  7145.                   GADGET_ATTACK:   begin
  7146.                                       OtherShipPtr:=FirstShip.NextShip;
  7147.                                       while (OtherShipPtr<>NIL) and (OtherShipPtr^.Owner=0) do OtherShipPtr:=OtherShipPtr^.NextShip;
  7148.                                       if (OtherShipPtr<>NIL) and (OtherShipPtr^.Owner<>ActPlayerFlag) then begin
  7149.                                          MyShipPtr^.Moving:=0;
  7150.                                          MyShipPtr^.PosX:=FromX;
  7151.                                          MyShipPtr^.PosY:=FromY;
  7152.                                          if STARTBIGSHIPFIGHT(MyShipPtr,OtherShipPtr,MODE_ALL,ActSys)=1 then begin
  7153.                                             AUTOVERHANDLUNG(ActPlayerFlag,PFlags and FLAG_CIV_MASK,ActSys,0);
  7154.                                             MyShipPtr^.Moving:=0;
  7155.                                             exit;
  7156.                                          end;
  7157.                                          AUTOVERHANDLUNG(ActPlayerFlag,PFlags and FLAG_CIV_MASK,ActSys,0);
  7158.                                          exit;
  7159.                                       end;
  7160.                                    end;
  7161.                   GADGET_ANGRIFF:  begin
  7162.                                       b:=true;
  7163.                                       STARLANDING(MyPlanetHeader,MyShipPtr,ActSys);
  7164.                                       AUTOVERHANDLUNG(ActPlayerFlag,MyPlanetHeader^.PFlags and FLAG_CIV_MASK,ActSys,0);
  7165.                                    end;
  7166.                   GADGET_ORBIT:    begin
  7167.                                       if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  7168.                                          XShipPtr:=^MyPlanetHeader^.FirstShip;
  7169.                                          while XShipPtr^.NextShip<>NIL do XShipPtr:=XShipPtr^.NextShip;
  7170.                                          XShipPtr^.NextShip:=MyShipPtr^.TargetShip;
  7171.                                          MyShipPtr^.TargetShip^.BeforeShip:=XShipPtr;
  7172.                                          MyShipPtr^.Owner:=0;
  7173.                                       end else begin
  7174.                                          LINKSHIP(MyShipPtr,^MyPlanetHeader^.FirstShip,1);
  7175.                                          DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7176.                                       end;
  7177.                                       exit;
  7178.                                    end;
  7179.                   GADGET_DIPLOMAT: begin
  7180.                                       DIPLOMACY;
  7181.                                       b:=true;
  7182.                                    end;
  7183.                   otherwise        with MyShipPtr^ do begin
  7184.                   {GADGET_LADEN,GADGET_LANDUNG}
  7185.                                       if MyPlanetHeader^.ProjectPtr=NIL then begin
  7186.                                          l:=AllocMem(sizeof(ByteArr42),MEMF_CLEAR);
  7187.                                          if l=0 then exit else ProjectPtr:=ptr(l);
  7188.                                          OldCiviPlanet:=false;
  7189.                                       end else OldCiviPlanet:=true;
  7190.                                       ActPProjects:=MyPlanetHeader^.ProjectPtr;
  7191.                                       ActPProjects^[0]:=1;
  7192.                                       b:=true;
  7193.                                       MAKELOADWINDOW;
  7194.                                       WRITELOADDATA;
  7195.                                       repeat
  7196.                                          delay(RDELAY);
  7197.                                          if (LData^ and 64=0) then begin
  7198.                                             if (MyPlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag) or
  7199.                                              (MyPlanetHeader^.Population=0) then begin
  7200.                                                if (IBase^.MouseX in [112..212]) and (IBase^.MouseY in [164..194])
  7201.                                                and (ActPProjects^[26]>0)
  7202.                                                and (ShipData[SType].MaxLoad>((Ladung and MASK_SIEDLER) div 16 + (Ladung and MASK_LTRUPPS)))
  7203.                                                and (15>(Ladung and MASK_SIEDLER) div 16)
  7204.                                                and (15>(Ladung and MASK_LTRUPPS))
  7205.                                                and (Fracht=0) then begin
  7206.                                                   PLAYSOUND(1,300);
  7207.                                                   ActPProjects^[26]:=ActPProjects^[26]-1;
  7208.                                                   Ladung:=Ladung+16;
  7209.                                                   SOut:=SOut-1;
  7210.                                                end;
  7211.                                                if (IBase^.MouseX in [112..212]) and (IBase^.MouseY in [228..258]) and
  7212.                                                   (ActPProjects^[26]<250) and ((Ladung and MASK_SIEDLER)>0)
  7213.                                                   and (Fracht=0) then begin
  7214.                                                   PLAYSOUND(1,300);
  7215.                                                   ActPProjects^[26]:=ActPProjects^[26]+1;
  7216.                                                   Ladung:=Ladung-16;
  7217.                                                   SOut:=SOut+1;
  7218.                                                end;
  7219.                                             end;
  7220.                                             if (MyPlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag) or
  7221.                                              (MyPlanetHeader^.Population>0) then begin
  7222.                                                if (IBase^.MouseX in [227..327]) and (IBase^.MouseY in [164..194])
  7223.                                                and (ActPProjects^[27]>0)
  7224.                                                and (ShipData[SType].MaxLoad>((Ladung and MASK_SIEDLER) div 16 + (Ladung and MASK_LTRUPPS)))
  7225.                                                and (15>(Ladung and MASK_SIEDLER) div 16)
  7226.                                                and (15>(Ladung and MASK_LTRUPPS))
  7227.                                                and (Fracht=0) and
  7228.                                                ((MyPlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag) or (LTOut>0)) then begin
  7229.                                                   PLAYSOUND(1,300);
  7230.                                                   ActPProjects^[27]:=ActPProjects^[27]-1;
  7231.                                                   Ladung:=Ladung+1;
  7232.                                                   LTOut:=LTOut-1;
  7233.                                                end;
  7234.                                                if (IBase^.MouseX in [227..327]) and (IBase^.MouseY in [228..258])
  7235.                                                and (ActPProjects^[27]<250) and ((Ladung and MASK_LTRUPPS)>0)
  7236.                                                and (Fracht=0) then begin
  7237.                                                   PLAYSOUND(1,300);
  7238.                                                   ActPProjects^[27]:=ActPProjects^[27]+1;
  7239.                                                   Ladung:=Ladung-1;
  7240.                                                   LTOut:=LTOut+1;
  7241.                                                end;
  7242.                                             end;
  7243.                                             if ((MyPlanetHeader^.PFlags and FLAG_CIV_MASK in [ActPlayerFlag,0]) or
  7244.                                                (ActPProjects^[34]=0) and (ActPProjects^[40]=0))
  7245.                                             and (MyPlanetHeader^.Class<>CLASS_STONES) then begin
  7246.                                                repeat
  7247.                                                   delay(RDELAY);
  7248.                                                   if (IBase^.MouseX in [342..442]) and (IBase^.MouseY in [164..194])
  7249.                                                   and (Ladung=0) and (Fracht<ShipData[SType].MaxLoad) and (Water>10) then begin
  7250.                                                      delay(7);
  7251.                                                      Fracht:=Fracht+1;
  7252.                                                      FIn:=FIn+1;
  7253.                                                      Water:=Water-5;
  7254.                                                      WRITELOADDATA;
  7255.                                                   end;
  7256.                                                   if (IBase^.MouseX in [342..442]) and (IBase^.MouseY in [228..258])
  7257.                                                   and (Fracht>0) and (Water div Size<100) then begin
  7258.                                                      delay(7);
  7259.                                                      Water:=Water+5;
  7260.                                                      FIn:=FIn-1;
  7261.                                                      Fracht:=Fracht-1;
  7262.                                                      WRITELOADDATA;
  7263.                                                   end;
  7264.                                                until not (LData^ and 64=0);
  7265.                                             end;
  7266.                                             WRITELOADDATA;
  7267.                                          end;
  7268.                                       until (RData^ and 1024=0);
  7269.                                       PLAYSOUND(1,300);
  7270.                                       RECT(MyScreen[1]^,0,42,148,469,273);
  7271.                                       REFRESHDISPLAY;
  7272.                                       if (MyPlanetHeader^.PFlags and FLAG_CIV_MASK<>ActPlayerFlag) then begin
  7273.                                          if (MyPlanetHeader^.PFlags and FLAG_CIV_MASK<>0) and (FIn>0)
  7274.                                           then AUTOVERHANDLUNG(ActPlayerFlag,MyPlanetHeader^.PFlags and FLAG_CIV_MASK,ActSys,0);
  7275.                                          if SOut>0 then begin
  7276.                                             Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+25;
  7277.                                             PFlags:=ActPlayerFlag or FLAG_KNOWN;
  7278.                                             Ethno:=ActPlayerFlag;
  7279.                                             Population:=Population+10*SOut;
  7280.                                             ActPProjects^[26]:=0;
  7281.                                             if not OldCiviPlanet then begin
  7282.                                                if Class=CLASS_EARTH then begin
  7283.                                                   Biosphäre:=200; Infrastruktur:=1; Industrie:=1;
  7284.                                                end else if Class in [CLASS_HALFEARTH,CLASS_WATER] then begin
  7285.                                                   Biosphäre:=90; Infrastruktur:=1; Industrie:=1;
  7286.                                                end else if Class=CLASS_DESERT then begin
  7287.                                                   Biosphäre:=50; Infrastruktur:=1; Industrie:=1;
  7288.                                                end else begin
  7289.                                                   Biosphäre:=30; Infrastruktur:=1; Industrie:=1;
  7290.                                                end;
  7291.                                             end;
  7292.                                             HANDLEKNOWNPLANET(ActSys,0,MyPlanetHeader);
  7293.                                          end;
  7294.                                          if LTOut>0 then begin
  7295.                                             CHECKPLANET(MyPlanetHeader);
  7296.                                             CHECKPROJECTS(MyPlanetHeader,ActPlayerFlag);
  7297.                                             AUTOVERHANDLUNG(ActPlayerFlag,MyPlanetHeader^.PFlags and FLAG_CIV_MASK,ActSys,0);
  7298.                                             REFRESHDISPLAY;
  7299.                                             Bool:=TAKETECH(ActPlayerFlag,PFlags and FLAG_CIV_MASK);
  7300.                                             if MyPlanetHeader^.XProjectPayed>1000 then begin
  7301.                                                s:=intstr(XProjectPayed div 5);
  7302.                                                REQUEST('Erbeutetes Vermögen:',s,ActPlayerFlag,12);
  7303.                                                Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]+(MyPlanetHeader^.XProjectPayed div 5);
  7304.                                                MyPlanetHeader^.XProjectPayed:=round(MyPlanetHeader^.XProjectPayed*0.8);
  7305.                                             end;
  7306.                                             PFlags:=ActPlayerFlag;
  7307.                                             if Population<Size*13 then Ethno:=ActPlayerFlag;
  7308.                                             HANDLEKNOWNPLANET(ActSys,0,MyPlanetHeader);
  7309.                                          end;
  7310.                                       end;
  7311.                                    end;
  7312.                end;
  7313.             end;
  7314.          end;
  7315.       until b or (RData^ and 1024=0);
  7316.       if (RData^ and 1024=0) then PLAYSOUND(1,300);
  7317.       RECT(MyScreen[1]^,0,194,119,318,280);
  7318.       REFRESHDISPLAY;
  7319.    end;
  7320.    PLANETHANDLING:=true;
  7321. end;
  7322.  
  7323.  
  7324.  
  7325. procedure DRAWMOVINGSHIP;
  7326.  
  7327. var Step        :byte;
  7328. var UseShipPtr  :^r_ShipHeader;
  7329.  
  7330.  
  7331.  
  7332. procedure FASTREFRESH(OldX,OldY :short; XCludeShip :ptr);
  7333.  
  7334. var x,y,i               :integer;
  7335. var OtherShipPtr        :^r_ShipHeader;
  7336. var PlanetHeader        :^r_PlanetHeader;
  7337.  
  7338. begin
  7339.    OtherShipPtr:=^SystemHeader[Display].FirstShip;
  7340.    repeat
  7341.       if (OtherShipPtr^.PosX in [pred(OldX)..succ(OldX)])
  7342.       and (OtherShipPtr^.PosY in [pred(OldY)..succ(OldY)]) then begin
  7343.          if ((OtherShipPtr<>XCludeShip) and (OtherShipPtr^.Owner>0)
  7344.          and (OtherShipPtr^.Moving>=0))
  7345.          or (OtherShipPtr^.SType=TARGET_STARGATE) then with OtherShipPtr^ do begin
  7346.             x:=256+(PosX+OffsetX)*32;
  7347.             y:=256+(PosY+OffsetY)*32;
  7348.             if OtherShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=OtherShipPtr^.TargetShip
  7349.             else UseShipPtr:=OtherShipPtr;
  7350.             if (x in [0..480]) and (y in [0..480]) then
  7351.              BltBitMapRastPort(^ImgBitMap4,(UseShipPtr^.SType-8)*32+1,33,^MyScreen[1]^.RastPort,x+1,y+1,30,30,192);
  7352.          end;
  7353.       end;
  7354.       OtherShipPtr:=OtherShipPtr^.NextShip;
  7355.    until OtherShipPtr=NIL;
  7356.  
  7357.    for i:=1 to SystemHeader[Display].Planets do begin
  7358.       PlanetHeader:=ptr(SystemHeader[Display].PlanetMemA+pred(i)*sizeof(r_PlanetHeader));
  7359.       if (round(PlanetHeader^.PosX) in [OldX-1..OldX+1]) and (round(PlanetHeader^.PosY) in [OldY-1..OldY+1])
  7360.       then with PlanetHeader^ do begin
  7361.          x:=256+round(PosX+OffsetX)*32;
  7362.          y:=256+round(PosY+OffsetY)*32;
  7363.          if (x in [0..480]) and (y in [0..480])
  7364.           then BltBitMapRastPort(^ImgBitMap7,Class*32,0,^MyScreen[1]^.RastPort,x,y,32,32,192);
  7365.       end;
  7366.    end;
  7367. end;
  7368.  
  7369.  
  7370.  
  7371. begin
  7372.    if Display=0 then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7373.    if (MyShipPtr^.PosX=FromX) and (MyShipPtr^.PosY=FromY) then exit;
  7374.    b:=true;
  7375.    if Save.FastMove then Step:=4 else Step:=2;
  7376.    repeat
  7377.       if (x in [0..480]) and (y in [0..480]) then begin
  7378.          FASTREFRESH(FromX,FromY,MyShipPtr);
  7379.          RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  7380.       end;
  7381.       if ToX<x then x:=x-Step else if ToX>x then x:=x+Step;
  7382.       if ToY<y then y:=y-Step else if ToY>y then y:=y+Step;
  7383.       if MyShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=MyShipPtr^.TargetShip
  7384.       else UseShipPtr:=MyShipPtr;
  7385.       if (x in [0..480]) and (y in [0..480]) then begin
  7386.          BltBitMapRastPort(^ImgBitMap4,(UseShipPtr^.SType-8)*32,32,^MyScreen[1]^.RastPort,x,y,31,31,192);
  7387.          SetAPen(^MyScreen[1]^.RastPort,UseShipPtr^.Owner);
  7388.          DRAWRECT(x,y);
  7389.          if MyShipPtr^.Owner<>FLAG_OTHER then begin
  7390.             WaitBlit; WaitBlit;
  7391.          end;
  7392.          WaitBlit; WaitTOF;
  7393.       end else b:=false;
  7394.    until (x=ToX) and (y=ToY);
  7395.    if not ((x in [1..478]) and (y in [1..478])) and (MyShipPtr^.Moving>0) and b then begin
  7396.       OffsetX:=-MyShipPtr^.PosX-1; OffsetY:=-MyShipPtr^.PosY-1;
  7397.       x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7398.       y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7399.       ToX:=x; ToY:=y;
  7400.       DRAWSYSTEM(MODE_REDRAW,Display,NIL);
  7401.    end else REFRESHDISPLAY;
  7402. end;
  7403.  
  7404.  
  7405.  
  7406. function CHECKSUN(ShipPtr: ptr):boolean;
  7407.  
  7408. var MyShipPtr   :^r_ShipHeader;
  7409.  
  7410. begin
  7411.    MyShipPtr:=ShipPtr;
  7412.    CHECKSUN:=false;
  7413.    with MyShipPtr^ do if (PosX in [-3..2]) and (PosY in [-3..2]) then begin
  7414.       if not ((FromX in [-3..2]) and (PosY in [-3..2])) then PosX:=FromX else
  7415.       if not ((PosX in [-3..2]) and (FromY in [-3..2])) then PosY:=FromY else begin
  7416.          PosX:=FromX;
  7417.          PosY:=FromY;
  7418.       end;
  7419.       if (PosX=FromX) and (PosY=FromY) then begin
  7420.          CHECKSUN:=true;
  7421.          MyShipPtr^.Moving:=0;
  7422.       end;
  7423.    end;
  7424. end;
  7425.  
  7426.  
  7427.  
  7428. procedure LINKTOORBIT(ActSys :byte);
  7429.  
  7430. var x,y         :word;
  7431.  
  7432. begin
  7433.    if (MyShipPtr^.Ladung and MASK_SIEDLER)=0 then LINKSHIP(MyShipPtr,^MyPlanetHeader^.FirstShip,1);
  7434.    if not (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0) or (MyShipPtr^.Owner=ActPlayerFlag) then begin
  7435.       x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7436.       y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7437.       if (x in [0..480]) and (y in [0..480]) then begin
  7438.          RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  7439.          REFRESHDISPLAY;
  7440.          delay(10);
  7441.       end;
  7442.    end;
  7443.    MyShipPtr^.PosX:=0; MyShipPtr^.PosY:=0;
  7444. end;
  7445.  
  7446.  
  7447.  
  7448. procedure DOWORMHANDLING(AMyShipPtr :ShipHeader);
  7449.  
  7450. var i,j,WormID,PosID,NewSys     :byte;
  7451.  
  7452. begin
  7453.    for i:=1 to MAXHOLES do with MyWormHole[i] do
  7454.     for j:=1 to 2 do if (System[j]=ActSys) and (PosX[j]=MyShipPtr^.PosX)
  7455.     and (PosY[j]=MyShipPtr^.PosY) then begin
  7456.       PosID:=3-j; WormID:=i; NewSys:=System[3-j];
  7457.    end;
  7458.    MyShipPtr^.Source:=0; MyShipPtr^.Target:=0;
  7459.    if Visible then begin
  7460.       DRAWMOVINGSHIP;
  7461.       if not ((ToX in [0..478]) and (ToY in [0..478])) then begin
  7462.          OffsetX:=-MyShipPtr^.PosX-1;
  7463.          OffsetY:=-MyShipPtr^.PosY-1;
  7464.          ToX:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7465.          ToY:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7466.          DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7467.       end;
  7468.       PLAYSOUND(3,280);
  7469.       for i:=15 downto 0 do begin
  7470.          BltBitMapRastPort(^ImgBitMap7,i*32,32,^MyScreen[1]^.RastPort,ToX,ToY,32,32,192);
  7471.          WaitTOF;   delay(4);
  7472.       end;
  7473.    end;
  7474.    if SystemHeader[NewSys].Planets=0 then CREATENEWSYSTEM(NewSys,ActPlayer);
  7475.    SystemFlags[ActPlayer,NewSys]:=SystemFlags[ActPlayer,NewSys] or FLAG_KNOWN;
  7476.    LINKSHIP(MyShipPtr,^SystemHeader[NewSys].FirstShip,1);
  7477.    MyShipPtr^.PosX:=MyWormHole[WormID].PosX[PosID];
  7478.    MyShipPtr^.PosY:=MyWormHole[WormID].PosY[PosID];
  7479.    repeat
  7480.       MyShipPtr^.PosX:=MyShipPtr^.PosX-1+random(3);
  7481.       MyShipPtr^.PosY:=MyShipPtr^.PosY-1+random(3);
  7482.    until not FINDOBJECT(NewSys,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr)
  7483.    or (MyShipPtr^.PosX in [-3..3]) or (MyShipPtr^.PosY in [-3..3]);
  7484.    if Visible then begin
  7485.       for i:=0 to 15 do begin
  7486.          BltBitMapRastPort(^ImgBitMap7,i*32,32,^MyScreen[1]^.RastPort,ToX,ToY,32,32,192);
  7487.          WaitTOF;   delay(4);
  7488.       end;
  7489.       RECT(MyScreen[1]^,0,ToX,ToY,ToX+31,ToY+31);
  7490.       REFRESHDISPLAY;
  7491.    end;
  7492.    MyShipPtr^.Moving:=MyShipPtr^.Moving-1;
  7493.    AUTOSHIPTRAVEL(NewSys,MODE_SHIPS,MyShipPtr);
  7494.    if Visible then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7495.    if MyShipPtr^.Moving=0 then MyShipPtr^.Moving:=1;
  7496. end;
  7497.  
  7498.  
  7499.  
  7500. function WORMHOLE(ShipPtr :ptr):boolean;
  7501.  
  7502. var SysID       :byte;
  7503. var Offset      :word;
  7504. var MyShipPtr   :^r_ShipHeader;
  7505.  
  7506.  
  7507. function WORMFLIGHT:boolean;
  7508.  
  7509. const STEPS=1100;
  7510.  
  7511. var i,j,k                       :integer;
  7512. var l,ShipShield                :long;
  7513. var AScr,RectCol                :byte;
  7514. var ImgBitMapW4                 :ITBitMap;
  7515. var FHandle                     :BPTR;
  7516. var WHSoundMemA,WHSoundMemL     :array [1..2] of long;
  7517. var Error                       :boolean;
  7518.  
  7519.  
  7520. procedure INITSOUNDS;
  7521.  
  7522. var l,ISize     :long;
  7523. var s           :string;
  7524.  
  7525.  
  7526. procedure LOADSOUND(FName :str; SID :byte);
  7527.  
  7528. var l           :long;
  7529.  
  7530. begin
  7531.    FHandle:=OPENSMOOTH(FName,MODE_OLDFILE);
  7532.    if FHandle=0 then exit;
  7533.    l:=DosSeek(FHandle,0,OFFSET_END);
  7534.    l:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  7535.    WHSoundMemL[SID]:=l div 2;
  7536.    if SID=1 then WHSoundMemL[SID]:=WHSoundMemL[SID]+STEPS*3;
  7537.    WHSoundMemA[SID]:=AllocMem(WHSoundMemL[SID]*2,MEMF_CHIP+MEMF_CLEAR);
  7538.    if WHSoundMemA[SID]=0 then begin
  7539.       DosClose(FHandle);   exit;
  7540.    end;
  7541.    l:=DosRead(FHandle,ptr(WHSoundMemA[SID]),WHSoundMemL[SID]*2);
  7542.    DosClose(FHandle);
  7543. end;
  7544.  
  7545.  
  7546.  
  7547. begin
  7548.    s:=PathStr[7]+'Sensor.RAW';
  7549.    LOADSOUND(s,1);                        {SFX/Sensor.RAW}
  7550.    s:=PathStr[7]+'FightSoundDS.RAW';
  7551.    LOADSOUND(s,2);                        {SFX/FightsoundDS.RAW}
  7552. end;
  7553.  
  7554.  
  7555.  
  7556. function INITIMAGES:boolean;
  7557.  
  7558. type r_Col=record;
  7559.         r,g,b   :byte
  7560.      end;
  7561.  
  7562. var IMem,ISize,AddrX    :long;
  7563. var ColorID             :^long;
  7564. var Col                 :^r_Col;
  7565.  
  7566.  
  7567. begin
  7568.    INITIMAGES:=false;
  7569.    s:=PathStr[5]+'Wormhole.img';
  7570.    if not RAWLOADIMAGE(s,0,0,640,512,4,ImgBitMapW4) then begin end;
  7571.    s:=PathStr[5]+'Wormhole.pal';
  7572.    l:=SETCOLOR(MyScreen[1]^,s);
  7573.    l:=SETCOLOR(MyScreen[2]^,s);
  7574.    INITIMAGES:=true;
  7575. end;
  7576.  
  7577.  
  7578.  
  7579. procedure TRAVEL;
  7580.  
  7581. var X,Y,S                               :array [1..5] of integer;
  7582. var XOff,YOff                           :integer;
  7583. var Joy                                 :^word;
  7584. var DirCnt,DVert,DHoriz,JVert,JHoriz    :short;
  7585. var Clear                               :integer;
  7586.  
  7587.  
  7588. begin
  7589.    for i:=1 to 2 do RECT(MyScreen[i]^,7,311,0,319,255);
  7590.    SPAddrA^:=WHSoundMemA[1]; SPLengthA^:=WHSoundMemL[1]; SPVolA^:=45; SPFreqA^:=300;
  7591.    SPAddrC^:=WHSoundMemA[2]; SPLengthC^:=WHSoundMemL[2] div 2; SPVolC^:=64; SPFreqC^:=400;
  7592.    SPAddrD^:=WHSoundMemA[2]+WHSoundMemL[2];
  7593.                              SPLengthD^:=WHSoundMemL[2] div 2; SPVolD^:=64; SPFreqD^:=400;
  7594.  
  7595.    SPAddrB^:=0; SPLengthB^:=1;
  7596.    DMACON_WRITE^:=$800F;
  7597.    randomize;
  7598.    X[1]:=155; Y[1]:=128; S[1]:=10; XOff:=0; YOff:=0; Clear:=0;
  7599.    for j:=1 to 4 do begin
  7600.       X[succ(j)]:=X[j];
  7601.       Y[succ(j)]:=Y[j];
  7602.       S[succ(j)]:=round(S[j]*1.6);
  7603.    end;
  7604.    AScr:=1; DirCnt:=1; DVert:=0; DHoriz:=0;
  7605.    Joy:=ptr($DFF00C);
  7606.    for i:=1 to STEPS do begin
  7607.       if i<(STEPS-55) then begin
  7608.          if DirCnt>8 then DirCnt:=0
  7609.          else if DirCnt=0 then begin
  7610.             DHoriz:=pred(random(3))*3;
  7611.             if DHoriz=0 then DVert:=pred(random(3))*3;
  7612.             DirCnt:=1;
  7613.          end else DirCnt:=DirCnt+1;
  7614.       end else begin
  7615.          DHoriz:=0; DVert:=0;
  7616.       end;
  7617.  
  7618.       JVert:=0; JHoriz:=0;
  7619.       if (Joy^ and $3 in [$3,$2]) then JHoriz:=-8 else if (Joy^ and $300 in [$300,$200]) then JHoriz:=8;
  7620.       if (Joy^ and $3 in [$1,$2]) then JVert:=8   else if (Joy^ and $300 in [$100,$200]) then JVert:=-8;
  7621.       if JHoriz<>0 then begin
  7622.          for j:=1 to 5 do X[j]:=X[j]+JHoriz;
  7623.          XOff:=XOff+JHoriz;
  7624.       end;
  7625.       if JVert<>0 then begin
  7626.          for j:=1 to 5 do Y[j]:=Y[j]+JVert;
  7627.          YOff:=YOff+JVert;
  7628.       end;
  7629.  
  7630.       XOff:=XOff+DHoriz;
  7631.       YOff:=YOff+DVert;
  7632.       if XOff>145 then XOff:=145;
  7633.       if XOff<-145 then XOff:=-145;
  7634.       if YOff>122 then YOff:=122;
  7635.       if YOff<-122 then YOff:=-122;
  7636.  
  7637.       for j:=1 to 5 do begin
  7638.          if X[j]<154 then X[j]:=round(155-(155-X[j])*0.98)
  7639.          else if X[j]>156 then X[j]:=round((X[j]-155)+0.98+155);
  7640.  
  7641.          if Y[j]<127 then Y[j]:=round(128-(128-Y[j])*0.98)
  7642.          else if Y[j]>129 then Y[j]:=round((Y[j]-128)+0.98+128);
  7643.  
  7644.          S[j]:=round(S[j]*1.06);
  7645.       end;
  7646.  
  7647.       if (S[5]>240) then begin
  7648.          for j:=4 downto 1 do begin
  7649.             X[succ(j)]:=X[j];
  7650.             Y[succ(j)]:=Y[j];
  7651.             S[succ(j)]:=S[j];
  7652.          end;
  7653.          X[1]:=155+XOff; Y[1]:=128+YOff; S[1]:=10;
  7654.       end;
  7655.  
  7656.       BltBitMapRastPort(^ImgBitMapW4,170-XOff,128-YOff,^MyScreen[AScr]^.RastPort,0,0,310,256,192);
  7657.       SetAPen(^MyScreen[Ascr]^.RastPort,6);
  7658.       for j:=1 to 5 do begin
  7659.          if (X[j]-S[j] in [1..309]) and (Y[j]-S[j] in [1..255])
  7660.          and (X[j]+S[j] in [1..309]) and (Y[j]+S[j] in [1..255]) then
  7661.           BOX(MyScreen[AScr]^,X[j]-S[j],Y[j]-S[j],X[j]+S[j],Y[j]+S[j]);
  7662.       end;
  7663.       if not (X[5] in [120..200]) or not (Y[5] in [90..165]) then begin
  7664.          if (X[5] in [105..215]) and (Y[5] in [75..180]) then begin
  7665.              SPFreqB^:=120;
  7666.              ShipShield:=ShipShield-2;
  7667.          end else begin
  7668.              SPFreqB^:=80;
  7669.              ShipShield:=ShipShield-4;
  7670.          end;
  7671.          SPAddrB^:=WHSoundMemA[1]; SPLengthB^:=1500; SPVolB^:=52;
  7672.          RectCol:=15;
  7673.          if ShipShield in [13..762] then RECT(MyScreen[AScr]^,0,312,1,318,round(258-ShipShield/3));
  7674.          if ShipShield<0 then begin
  7675.             DMACON_WRITE^:=$000F;
  7676.             for j:=1 to random(5)+5 do begin
  7677.                PLAYSOUND(2,1100);
  7678.                SetRGB4(^MyScreen[3-Ascr]^.ViewPort,0,8,8,15);
  7679.                delay(3);
  7680.                SetRGB4(^MyScreen[3-Ascr]^.ViewPort,0,0,0,3);
  7681.                delay(3);
  7682.             end;
  7683.             exit;
  7684.          end;
  7685.       end else RectCol:=9;
  7686.  
  7687.       SetAPen(^MyScreen[Ascr]^.RastPort,5);
  7688.       Move(^MyScreen[Ascr]^.RastPort,XOff+150,YOff+128);
  7689.       for j:=1 to 5 do if (X[j]-S[j] in [1..309]) and (Y[j]-S[j] in [1..255]) then
  7690.       Draw(^MyScreen[Ascr]^.RastPort,X[j]-S[j],Y[j]-S[j]);
  7691.  
  7692.       Move(^MyScreen[Ascr]^.RastPort,XOff+150,YOff+128);
  7693.       for j:=1 to 5 do if (X[j]+S[j] in [1..309]) and (Y[j]-S[j] in [1..255]) then
  7694.       Draw(^MyScreen[Ascr]^.RastPort,X[j]+S[j],Y[j]-S[j]);
  7695.  
  7696.       Move(^MyScreen[Ascr]^.RastPort,XOff+150,YOff+128);
  7697.       for j:=1 to 5 do if (X[j]+S[j] in [1..309]) and (Y[j]+S[j] in [1..255]) then
  7698.       Draw(^MyScreen[Ascr]^.RastPort,X[j]+S[j],Y[j]+S[j]);
  7699.  
  7700.       Move(^MyScreen[Ascr]^.RastPort,XOff+150,YOff+128);
  7701.       for j:=1 to 5 do if (X[j]-S[j] in [1..309]) and (Y[j]+S[j] in [1..255]) then
  7702.       Draw(^MyScreen[Ascr]^.RastPort,X[j]-S[j],Y[j]+S[j]);
  7703.  
  7704.       SetAPen(^MyScreen[Ascr]^.RastPort,RectCol);
  7705.       BOX(MyScreen[Ascr]^,60,35,250,220);
  7706.  
  7707.       SPAddrB^:=ZeroSound; SPLengthB^:=1;
  7708.       if i>(STEPS-30) then begin
  7709.          SPAddrA^:=ZeroSound; SPLengthA^:=1;
  7710.          Clear:=Clear+4;
  7711.          RECT(MyScreen[AScr]^,0,160-Clear,128-Clear,160+Clear,128+Clear);
  7712.       end else SPLengthA^:=WHSoundMemL[1]-i-i-i;
  7713.       ScreenToFront(MyScreen[Ascr]);
  7714.       AScr:=3-AScr;
  7715.    end;
  7716. end;
  7717.  
  7718.  
  7719.  
  7720. function SMALLWORMFLIGHT:boolean;
  7721.  
  7722. begin
  7723.    ShipShield:=round(ShipShield*(random(45)+15)/100);
  7724.    if ShipShield<=0 then SMALLWORMFLIGHT:=false else begin
  7725.       with MyShipPtr^ do Shield:=round(ShipShield / 760 * ShipData[SType].MaxShield);
  7726.       SMALLWORMFLIGHT:=true;
  7727.    end;
  7728. end;
  7729.  
  7730.  
  7731.  
  7732. procedure WORMEXIT;
  7733.  
  7734. begin
  7735.    DoClock:=false;
  7736.    CLOSEMYSCREENS;
  7737.    for i:=1 to 2 do if WHSoundMemA[i]<>0 then begin
  7738.       FreeMem(WHSoundMemA[i],WHSoundMemL[i]*2);
  7739.       WHSoundMemA[i]:=0;
  7740.    end;
  7741.    if ImgBitMapW4.MemA<>0 then FreeMem(ImgBitMapW4.MemA,ImgBitMapW4.MemL);
  7742.    ImgBitMapW4.MemA:=0;
  7743.    DMACON_WRITE^:=$000F;
  7744.    b:=OPENMAINSCREENS;
  7745.    b:=INITDESK(0);
  7746.    if Error then WORMFLIGHT:=SMALLWORMFLIGHT;
  7747.    Screen2:=0;   Display:=0;
  7748.    DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7749. end;
  7750.  
  7751.  
  7752.  
  7753. begin
  7754.    Error:=true;
  7755.    MyShipPtr:=ShipPtr;
  7756.    with MyShipPtr^ do ShipShield:=round(Shield / ShipData[SType].MaxShield * 760);
  7757.    if Save.NoWorm then begin
  7758.       WORMFLIGHT:=SMALLWORMFLIGHT;
  7759.       exit;
  7760.    end;
  7761.    for i:=1 to 2 do WHSoundMemA[i]:=0;
  7762.    CLOSEMYSCREENS;
  7763.    ImgBitMapW4:=ITBitMap(0,0,0,0,0,NIL,NIL,NIL,NIL,NIL,NIL,NIL,NIL,0,0);
  7764.    with ImgBitMapW4 do begin
  7765.       MemL:=163840;  {640 x 512 x 4}
  7766.       MemA:=AllocMem(MemL,MEMF_CHIP+MEMF_CLEAR);
  7767.       if MemA=0 then exit;
  7768.       ImgBitMapW4:=ITBitMap(80,512,1,4,0,ptr(MemA),       ptr(MemA+40960),ptr(MemA+81920),
  7769.                                          ptr(MemA+122880),NIL,NIL,NIL,NIL,MemA,MemL);
  7770.    end;
  7771.    Tags:=TagArr(SA_DisplayID,   ($1000+HelpID),
  7772.                 SA_Interleaved, _TRUE,
  7773.                 SA_Draggable,   _FALSE,
  7774.                 SA_COLORS,      addr(ColSpec),
  7775.                 TAG_DONE,       0,0,0,0,0);
  7776.    NeuScreen:=NewScreen(0,0,320,256,4,0,0,GENLOCK_VIDEO,CUSTOMSCREEN+SCREENQUIET,
  7777.                         NIL,'',NIL,NIL);
  7778.    for i:=1 to 2 do MyScreen[i]:=OpenScreenTagList(^NeuScreen,^Tags);
  7779.    if MyScreen[1]=NIL then begin
  7780.       WORMEXIT;
  7781.       exit;
  7782.    end;
  7783.    if MyScreen[2]=NIL then begin
  7784.       WORMEXIT;
  7785.       exit;
  7786.    end;
  7787.    if not INITIMAGES then begin
  7788.       WORMEXIT; exit;
  7789.    end;
  7790.    INITSOUNDS;
  7791.    TRAVEL;
  7792.    if ShipShield<=0 then WORMFLIGHT:=false else begin
  7793.       with MyShipPtr^ do Shield:=round(ShipShield / 760 * ShipData[SType].MaxShield);
  7794.       WORMFLIGHT:=true;
  7795.    end;
  7796.    Error:=false;
  7797.    WORMEXIT;
  7798. end;
  7799.  
  7800.  
  7801.  
  7802. begin
  7803.    MyShipPtr:=ShipPtr;
  7804.    if not ((ToX in [0..478]) and (ToY in [0..478])) then begin
  7805.       OffsetX:=-MyShipPtr^.PosX-1;
  7806.       OffsetY:=-MyShipPtr^.PosY-1;
  7807.       ToX:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7808.       ToY:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7809.       DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7810.    end;
  7811.    PLAYSOUND(3,250);
  7812.    delay(7);
  7813.    for i:=15 downto 0 do begin
  7814.       BltBitMapRastPort(^ImgBitMap7,i*32,32,^MyScreen[1]^.RastPort,ToX,ToY,32,32,192);
  7815.       WaitTOF;   delay(4);
  7816.    end;
  7817.    if ToY>210 then Offset:=110 else Offset:=260;
  7818.    SysID:=succ(random(Save.SYSTEMS));
  7819.    MAKEBORDER(MyScreen[1]^,70,Offset,440,Offset+85,12,6,0);
  7820.    WRITE(256,Offset+13,ActPlayerFlag,16,MyScreen[1]^,4,'Raumschiff gerät in Wurmloch!' );
  7821.    WRITE(256,Offset+35,ActPlayerFlag,16,MyScreen[1]^,4,'Das Ende des Loches befindet sich');
  7822.    s:='im System '+Save.SystemName[SysID];
  7823.    WRITE(256,Offset+57,ActPlayerFlag,16,MyScreen[1]^,4,s);
  7824.    if SystemHeader[SysID].Planets=0 then CREATENEWSYSTEM(SysID,ActPlayer);
  7825.    SystemFlags[ActPlayer,SysID]:=SystemFlags[ActPlayer,SysID] or FLAG_KNOWN;
  7826.    LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,1);
  7827.    repeat
  7828.       MyShipPtr^.PosX:=random(80)-40;
  7829.       MyShipPtr^.PosY:=random(80)-40;
  7830.    until not FINDOBJECT(SysID,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr)
  7831.    or (MyShipPtr^.PosX in [-3..3]) or (MyShipPtr^.PosY in [-3..3]);
  7832.  
  7833.    WAITLOOP(false);
  7834.    RECT(MyScreen[1]^,0,70,Offset,440,Offset+85);
  7835.    if random(100)<10 then REQUEST('Glück gehabt, es war nicht','der Gamma-Quadrant!',12,12);
  7836.    REFRESHDISPLAY;
  7837.  
  7838.    PLAYSOUND(3,250);
  7839.    delay(7);
  7840.    for i:=0 to 15 do begin
  7841.       BltBitMapRastPort(^ImgBitMap7,i*32,32,^MyScreen[1]^.RastPort,ToX,ToY,32,32,192);
  7842.       WaitTOF;   delay(4);
  7843.    end;
  7844.    RECT(MyScreen[1]^,0,ToX,ToY,ToX+31,ToY+31);
  7845.    delay(20);
  7846.    if WORMFLIGHT then begin
  7847.       WORMHOLE:=true;
  7848.       AUTOSHIPTRAVEL(SysID,MODE_SHIPS,MyShipPtr);
  7849.       if not (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0)
  7850.       or (MyShipPtr^.Owner=ActPlayerFlag) then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7851.       if MyShipPtr^.Moving=0 then MyShipPtr^.Moving:=1;
  7852.    end else WORMHOLE:=false;
  7853. end;
  7854.  
  7855.  
  7856.  
  7857. procedure FADESTARGATE(SysID,ActSys :byte; MyShipPtr :ShipHeader);
  7858.  
  7859. var UseShipPtr        :^r_ShipHeader;
  7860. var i                 :integer;
  7861. var Color,Cx,Cy       :byte;
  7862.  
  7863. begin
  7864.    if MyShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=MyShipPtr^.TargetShip
  7865.    else UseShipPtr:=MyShipPtr;
  7866.  
  7867.    if ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN) and (Save.CivPlayer[ActPlayer]<>0))
  7868.    or (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0) then begin
  7869.       if not (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0) then DRAWMOVINGSHIP;
  7870.       PLAYSOUND(3,250);
  7871.       if (ToX in [0..478]) and (ToY in [0..478]) then for i:=1 to 1800 do begin
  7872.          Cx:=succ(random(29));
  7873.          Cy:=succ(random(29));
  7874.          BltBitMapRastPort(^ImgBitMap4,576+Cx,32+Cy,^MyScreen[1]^.RastPort,ToX+Cx,ToY+Cy,1,1,192);
  7875.          Color:=ReadPixel(^MyScreen[1]^.RastPort,ToX+Cx,ToY+Cy);
  7876.          SetAPen(^MyScreen[1]^.RastPort,Color);
  7877.          RectFill(^MyScreen[1]^.RastPort,ToX+Cx,ToY+Cy,succ(ToX+Cx),succ(ToY+Cy));
  7878.       end;
  7879.    end;
  7880.    LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,1);
  7881.    delay(5);
  7882.    REFRESHDISPLAY;
  7883.    delay(5);
  7884.    MyShipPtr^.PosX:=SystemHeader[SysID].FirstShip.PosX;
  7885.    MyShipPtr^.PosY:=SystemHeader[SysID].FirstShip.PosY;
  7886.    OffsetX:=-MyShipPtr^.PosX-1;
  7887.    OffsetY:=-MyShipPtr^.PosY-1;
  7888.    x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7889.    y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7890.    if ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN) and (Save.CivPlayer[ActPlayer]<>0))
  7891.    or (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0) then begin
  7892.       if (x in [0..478]) and (y in [0..478]) then begin
  7893.          MyShipPtr^.Moving:=-MyShipPtr^.Moving;
  7894.          if MyShipPtr^.Moving=0 then MyShipPtr^.Moving:=-1;
  7895.          DRAWSYSTEM(MODE_REDRAW,SysID,NIL);
  7896.          delay(5);
  7897.          if (x in [0..478]) and (y in [0..478]) then for i:=1 to 1800 do begin
  7898.             Cx:=succ(random(29));
  7899.             Cy:=succ(random(29));
  7900.             BltBitMapRastPort(^ImgBitMap4,(UseShipPtr^.Stype-8)*32+Cx,32+Cy,^MyScreen[1]^.RastPort,x+Cx,y+Cy,2,1,192);
  7901.             Color:=ReadPixel(^MyScreen[1]^.RastPort,x+Cx,y+Cy);
  7902.             SetAPen(^MyScreen[1]^.RastPort,Color);
  7903.             RectFill(^MyScreen[1]^.RastPort,x+Cx,y+Cy,succ(x+Cx),succ(y+Cy));
  7904.          end;
  7905.          delay(5);
  7906.          MyShipPtr^.Moving:=-MyShipPtr^.Moving;
  7907.          DRAWSYSTEM(MODE_REFRESH,SysID,NIL);
  7908.          delay(5);
  7909.       end;
  7910.    end;
  7911.    FromX:=MyShipPtr^.PosX;
  7912.    FromY:=MyShipPtr^.PosY;
  7913.    repeat
  7914.       with MyShipPtr^ do case random(4) of
  7915.          0: PosX:=PosX+1;
  7916.          1: PosY:=PosY+1;
  7917.          2: PosX:=PosX-1;
  7918.          3: PosY:=PosY-1;
  7919.       end;
  7920.    until not FINDOBJECT(SysID,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr);
  7921.    ToX:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7922.    ToY:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7923.    if ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN)
  7924.     and (Save.CivPlayer[ActPlayer]<>0))
  7925.     or (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0) then DRAWMOVINGSHIP;
  7926.    if MyShipPtr^.Flags=SHIPFLAG_WATER then  SysID:=FINDNEXTPLANET(SysID,MyShipPtr);
  7927.    MyShipPtr^.Moving:=MyShipPtr^.Moving-1;
  7928.    if MyShipPtr^.Owner=FLAG_OTHER then MyShipPtr^.Moving:=0;
  7929.    AUTOSHIPTRAVEL(SysID,MODE_SHIPS,MyShipPtr);
  7930.    if MyShipPtr^.Owner=0 then exit;
  7931.    if ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN)
  7932.     and (Save.CivPlayer[ActPlayer]<>0))
  7933.     or (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0) then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  7934. end;
  7935.  
  7936.  
  7937.  
  7938. function AUTOWATERTRANSPORT(MyPlanetHeader :PlanetHeader):boolean;
  7939.  
  7940. begin
  7941.    AUTOWATERTRANSPORT:=true;
  7942.    if MyShipPtr^.Fracht=0 then with MyPlanetHeader^ do begin
  7943.       if (Water div Size>56) and not (Class in [CLASS_STONES,CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM])
  7944.       then begin
  7945.          while (MyShipPtr^.Fracht<ShipData[MyShipPtr^.SType].MaxLoad)
  7946.          and ((Water-5) div Size>56) do begin
  7947.             MyShipPtr^.Fracht:=MyShipPtr^.Fracht+1;
  7948.             Water:=Water-5;
  7949.          end;
  7950.          l:=FINDNEXTPLANET(ActSys,MyShipPtr);
  7951.          if MyShipPtr^.Moving>0 then MyShipPtr^.Moving:=0;
  7952.          exit;
  7953.       end;
  7954.    end else with MyPlanetHeader^ do begin
  7955.       if (Water div Size<55) and not (Class in [CLASS_STONES,CLASS_GAS,CLASS_SATURN,CLASS_PHANTOM])
  7956.       then begin
  7957.          while (MyShipPtr^.Fracht>0) and (Water div Size<55) do begin
  7958.             MyShipPtr^.Fracht:=MyShipPtr^.Fracht-1;
  7959.             Water:=Water+5;
  7960.          end;
  7961.          l:=FINDNEXTPLANET(ActSys,MyShipPtr);
  7962.          if MyShipPtr^.Moving>0 then MyShipPtr^.Moving:=0;
  7963.          exit;
  7964.       end;
  7965.    end;
  7966.    AUTOWATERTRANSPORT:=false;
  7967. end;
  7968.  
  7969.  
  7970.  
  7971. procedure SUPPORTCIVI(XValue :long);
  7972.  
  7973. var CivVar      :byte;
  7974.  
  7975. begin
  7976.    if Save.WorldFlag=WFLAG_JAHADR then Save.Staatstopf[8]:=Save.Staatstopf[8]+XValue
  7977.    else if MultiPlayer then begin
  7978.       CivVar:=random(MAXCIVS-2)+1;
  7979.       if (Save.CivPlayer[CivVar]=0) and (Save.WarState[CivVar,CivVar]<>LEVEL_DIED)
  7980.        then Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]+XValue;
  7981.    end;
  7982. end;
  7983.  
  7984.  
  7985.  
  7986. begin; {MOVESHIP}
  7987.    CLOCK;
  7988.    OldMoving:=0; l:=0;
  7989.    MyShipPtr:=ShipPtr;
  7990.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  7991.    if (CivVar=0) or (MyShipPtr^.Moving<=0) then exit;
  7992.    x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  7993.    y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  7994.    if (not ((x in [1..478]) and (y in [1..478])) and (Display=ActSys))
  7995.    and ((SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN)
  7996.    or Visible) then begin
  7997.       OffsetX:=-MyShipPtr^.PosX-1;
  7998.       OffsetY:=-MyShipPtr^.PosY-1;
  7999.       x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  8000.       y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  8001.       if ((MyShipPtr^.Owner=ActPlayerFlag) and (Save.CivPlayer[ActPlayer]<>0))
  8002.       or Visible then DRAWSYSTEM(MODE_REDRAW,ActSys,MyShipPtr);
  8003.    end;
  8004.    if MyShipPtr^.Owner=ActPlayerFlag then RECT(MyScreen[1]^,0,520,291,632,308);
  8005.    if (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]=0)
  8006.    or (MyShipPtr^.Flags=SHIPFLAG_WATER) or Save.PlayMySelf then begin
  8007.       if (MyShipPtr^.Moving=1) and (Year mod 2=0) then MyShipPtr^.Moving:=MyShipPtr^.Moving+1;
  8008.       delay(2);
  8009.       repeat
  8010.          FromX:=MyShipPtr^.PosX;
  8011.          FromY:=MyShipPtr^.PosY;
  8012.          if (MyShipPtr^.SType=21) and (SystemHeader[ActSys].FirstShip.SType<>TARGET_STARGATE) then
  8013.          with MyShipPtr^ do begin
  8014.          {*** STARGATE INSTALLIEREN ***}
  8015.             if SQRT((PosX*PosX)+(PosY*PosY))<10 then begin
  8016.                if not FINDOBJECT(ActSys,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr) then begin
  8017.                   SystemHeader[ActSys].FirstShip.SType:=TARGET_STARGATE;
  8018.                   SystemHeader[ActSys].FirstShip.PosX:=MyShipPtr^.PosX;
  8019.                   SystemHeader[ActSys].FirstShip.PosY:=MyShipPtr^.PosY;
  8020.                   Owner:=0;
  8021.                   if (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=FLAG_KNOWN) then REFRESHDISPLAY;
  8022.                   delay(20);
  8023.                end else Moving:=0;
  8024.                exit;
  8025.             end;
  8026.             if 0<PosX then PosX:=PosX-1 else if 0>PosX then PosX:=PosX+1;
  8027.             if 0<PosY then PosY:=PosY-1 else if 0>PosY then PosY:=PosY+1;
  8028.          end else if MyShipPtr^.Target=TARGET_ENEMY_SHIP then begin
  8029.          {*** FEINDLICHES SCHIFF ABFANGEN ***}
  8030.             if MyShipPtr^.TargetShip^.PosX<MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX-1 else
  8031.              if MyShipPtr^.TargetShip^.PosX>MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX+1;
  8032.             if MyShipPtr^.TargetShip^.PosY<MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY-1 else
  8033.              if MyShipPtr^.TargetShip^.PosY>MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY+1;
  8034.          end else with MyShipPtr^ do if (Source<0)and (Target<0) then begin
  8035.          {*** STABILES WURMLOCH BENUTZEN ***}
  8036.             if MyWormHole[-Target].PosX[-Source]<MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX-1 else
  8037.              if MyWormHole[-Target].PosX[-Source]>MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX+1;
  8038.             if MyWormHole[-Target].PosY[-Source]<MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY-1 else
  8039.              if MyWormHole[-Target].PosY[-Source]>MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY+1;
  8040.          end else begin
  8041.          {*** PLANETEN ANFLIEGEN ***}
  8042.             while MyShipPtr^.Target>SystemHeader[ActSys].Planets do begin
  8043.                { Unkorrektes Ziel für Bewässerung }
  8044.                SysID:=FINDNEXTPLANET(ActSys,MyShipPtr);
  8045.                if ActSys<>SysID then AUTOSHIPTRAVEL(SysID,MODE_SHIPS,MyShipPtr);
  8046.             end;
  8047.             MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+pred(MyShipPtr^.Target)*sizeof(r_PlanetHeader));
  8048.             if round(MyPlanetHeader^.PosX)<MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX-1 else
  8049.              if round(MyPlanetHeader^.PosX)>MyShipPtr^.PosX then MyShipPtr^.PosX:=MyShipPtr^.PosX+1;
  8050.             if round(MyPlanetHeader^.PosY)<MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY-1 else
  8051.              if round(MyPlanetHeader^.PosY)>MyShipPtr^.PosY then MyShipPtr^.PosY:=MyShipPtr^.PosY+1;
  8052.          end;
  8053.          if CHECKSUN(MyShipPtr) then exit;
  8054.          ToX:=256+(MyShipPtr^.PosX+OffsetX)*32;
  8055.          ToY:=256+(MyShipPtr^.PosY+OffsetY)*32;
  8056.          if (abs(MyShipPtr^.PosX)>50) or (abs(MyShipPtr^.PosY)>50)
  8057.          or not (MyShipPtr^.Target in [1..SystemHeader[ActSys].Planets,TARGET_POSITION,TARGET_STARGATE,TARGET_ENEMY_SHIP]) then begin
  8058.             {Bugfix Mad Ship}
  8059.             MyShipPtr^.Owner:=0;
  8060.             exit;
  8061.          end;
  8062.          if FINDOBJECT(ActSys,ToX+16,ToY+16,MyShipPtr) then begin
  8063.             if MyShipPtr^.Flags=SHIPFLAG_WATER then with MyShipPtr^ do begin
  8064.                if not (ObjType in [TYPE_STARGATE,TYPE_WORMHOLE]) then begin
  8065.                   PosX:=FromX;
  8066.                   PosY:=FromY;
  8067.                   {if ObjType<>TYPE_PLANET then ObjType:=0;}
  8068.                end;
  8069.             end;
  8070.             case ObjType of
  8071.                TYPE_PLANET: if MyShipPtr^.Flags=SHIPFLAG_WATER then begin
  8072.                                SystemFlags[ActPlayer,ActSys]:=SystemFlags[ActPlayer,ActSys] or FLAG_KNOWN;
  8073.                                if AUTOWATERTRANSPORT(ObjPtr) then exit;
  8074.                                MyShipPtr^.Moving:=0;
  8075.                             end else begin
  8076.                                if long(ObjPtr)=SystemHeader[ActSys].PlanetMemA+pred(MyShipPtr^.Target)*sizeof(r_PlanetHeader) then begin
  8077.                                   MyShipPtr^.PosX:=FromX;
  8078.                                   MyShipPtr^.PosY:=FromY;
  8079.                                   MyPlanetHeader:=ptr(ObjPtr);
  8080.                                   OtherShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  8081.                                   while (OtherShipPtr<>NIL) and (OtherShipPtr^.Owner=0) do OtherShipPtr:=OtherShipPtr^.NextShip;
  8082.                                   if (OtherShipPtr<>NIL) and (Save.WarState[CivVar,GETCIVVAR(MyPlanetHeader^.PFlags)] in [LEVEL_WAR,LEVEL_COLDWAR]) then begin
  8083.                                      {*** Feindliches Schiff im Orbit ***}
  8084.                                      if (Save.CivPlayer[ActPlayer]=0)
  8085.                                       and (Save.CivPlayer[GETCIVVAR(MyPlanetHeader^.PFlags)]<>0) then exit;
  8086.                                      if Save.WarState[CivVar,GETCIVVAR(MyPlanetHeader^.PFlags)]=LEVEL_COLDWAR then GOTOWAR(MyShipPtr^.Owner,MyPlanetHeader^.PFlags);
  8087.                                      MyShipPtr^.Moving:=0;
  8088.                                      if OtherShipPtr^.Owner<>MyShipPtr^.Owner then begin
  8089.                                         delay(20);
  8090.                                         if BIGSHIPFIGHT(MyShipPtr,OtherShipPtr,MODE_ALL,ActSys)=1 then exit;
  8091.                                         REFRESHDISPLAY;
  8092.                                         delay(10);
  8093.                                         AUTOVERHANDLUNG(MyShipPtr^.Owner,MyPlanetHeader^.PFlags,ActSys,0);
  8094.                                         exit;
  8095.                                      end;
  8096.                                      LINKTOORBIT(ActSys);
  8097.                                      exit
  8098.                                   end else if ((MyPlanetHeader^.PFlags and FLAG_CIV_MASK)=0) then begin
  8099.                                      if (MyShipPtr^.Ladung and MASK_SIEDLER>0) and (MyPlanetHeader^.Class in [CLASS_DESERT,CLASS_HALFEARTH,
  8100.                                      CLASS_EARTH,CLASS_ICE,CLASS_STONES,CLASS_WATER]) then with MyPlanetHeader^ do begin
  8101.                                         {*** Planet unbewohnt ***}
  8102.                                         if ProjectPtr<>NIL then begin
  8103.                                            ActPProjects:=MyPlanetHeader^.ProjectPtr;
  8104.                                            if (ActPProjects^[34]>0) or (ActPProjects^[40]>0) then begin
  8105.                                               SMALLANDING(MyPlanetHeader,MyShipPtr,ActSys);
  8106.                                               exit;
  8107.                                            end;
  8108.                                         end;
  8109.                                         Save.ImperatorState[CivVar]:=Save.ImperatorState[CivVar]+25;
  8110.                                         if ProjectPtr=NIL then begin
  8111.                                            l:=AllocMem(sizeof(ByteArr42),MEMF_CLEAR);
  8112.                                            if l=0 then exit else ProjectPtr:=ptr(l);
  8113.                                         end else l:=13;
  8114.                                         ActPPRojects:=ProjectPtr;
  8115.                                         ActPProjects^[0]:=1;
  8116.                                         if SystemFlags[1,ActSys] and FLAG_CIV_MASK=0 then SystemFlags[1,ActSys]:=MyShipPtr^.Owner;
  8117.                                         PFlags:=MyShipPtr^.Owner;
  8118.                                         Ethno:=MyShipPtr^.Owner;
  8119.                                         MyShipPtr^.Ladung:=MyShipPtr^.Ladung-16;
  8120.                                         Population:=Population+10;
  8121.                                         if l<>13 then begin
  8122.                                            if Class=CLASS_EARTH then begin
  8123.                                               Biosphäre:=200; Infrastruktur:=1; Industrie:=1;
  8124.                                            end else if Class in [CLASS_HALFEARTH,CLASS_WATER] then begin
  8125.                                               Biosphäre:=90; Infrastruktur:=1; Industrie:=1;
  8126.                                            end else if Class=CLASS_DESERT then begin
  8127.                                               Biosphäre:=50; Infrastruktur:=1; Industrie:=1;
  8128.                                            end else begin
  8129.                                               Biosphäre:=30; Infrastruktur:=1; Industrie:=1;
  8130.                                            end;
  8131.                                         end;
  8132.                                         if (MyShipPtr^.Ladung and MASK_SIEDLER)>0 then begin
  8133.                                            SysID:=FINDNEXTPLANET(ActSys,MyShipPtr);
  8134.                                            if ActSys<>SysID then AUTOSHIPTRAVEL(SysID,MODE_SHIPS,MyShipPtr);
  8135.                                         end;
  8136.                                      end;
  8137.                                      if not (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0) then begin
  8138.                                         REFRESHDISPLAY;
  8139.                                         delay(10);
  8140.                                      end;
  8141.                                      MyShipPtr^.Moving:=0;
  8142.                                      exit;
  8143.                                   end else if (MyPlanetHeader^.PFlags and FLAG_CIV_MASK=MyShipPtr^.Owner)
  8144.                                   and (MyShipPtr^.Ladung and MASK_SIEDLER=0) then begin
  8145.                                      if AUTOWATERTRANSPORT(MyPlanetHeader) then exit;
  8146.                                      {*** Eigener Planet, Schiff ohne Siedler, kein Wassertransport ***}
  8147.                                      LINKTOORBIT(ActSys);
  8148.                                      exit;
  8149.                                   end else if Save.WarState[CivVar,GETCIVVAR(MyPlanetHeader^.PFlags)] in [LEVEL_WAR,LEVEL_COLDWAR] then begin
  8150.                                      {*** Feindlicher Planet ***}
  8151.                                      if (Save.CivPlayer[ActPlayer]=0)
  8152.                                       and (Save.CivPlayer[GETCIVVAR(MyPlanetHeader^.PFlags)]<>0) then exit;
  8153.                                      if Save.WarState[CivVar,GETCIVVAR(MyPlanetHeader^.PFlags)]=LEVEL_COLDWAR then GOTOWAR(MyShipPtr^.Owner,MyPlanetHeader^.PFlags);
  8154.                                      ActPProjects:=MyPlanetHeader^.ProjectPtr;
  8155.                                      if (ActPProjects^[34]>0) or (ActPProjects^[40]>0) then begin
  8156.                                         if (Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]<>0)
  8157.                                          or (Save.CivPlayer[GETCIVVAR(MyPlanetHeader^.PFlags)]<>0)
  8158.                                          then DRAWSCENE(ActSys);
  8159.                                         SMALLANDING(MyPlanetHeader,MyShipPtr,ActSys);
  8160.                                         exit;
  8161.                                      end;
  8162.                                      if (Save.WorldFlag=WFLAG_CEBORC) and (CivVar=8) then begin
  8163.                                         with MyPlanetHeader^ do begin
  8164.                                            PFlags:=0;
  8165.                                            Ethno:=0;         Population:=0;
  8166.                                            Biosphäre:=random(150);
  8167.                                            Industrie:=random(150); Infrastruktur:=random(150);
  8168.                                            XProjectCosts:=0; XProjectPayed:=0;
  8169.                                            ProjectID:=0;
  8170.                                         end;
  8171.                                         for j:=1 to 42 do ActPProjects^[j]:=0;
  8172.                                         if Visible then begin
  8173.                                            PLAYSOUND(2,1300);
  8174.                                            REFRESHDISPLAY;
  8175.                                            delay(20);
  8176.                                         end;
  8177.                                         exit;
  8178.                                      end else if CivVar=9 then begin
  8179.                                         with MyPlanetHeader^ do begin
  8180.                                            Population:=round(Population*0.99);
  8181.                                            Biosphäre:=round(Biosphäre*0.97);
  8182.                                            Industrie:=round(Industrie*0.95);
  8183.                                            Infrastruktur:=round(Infrastruktur*0.93);
  8184.                                            s:='Maquis plündern Planeten '+PName;
  8185.                                            s2:='und rauben '+intstr(XProjectPayed div 5)+'!';
  8186.                                            if Visible then REQUEST(s,s2,12,12);
  8187.                                            SUPPORTCIVI(XProjectPayed div 5);
  8188.                                            XProjectPayed:=round(XProjectPayed*0.8);
  8189.                                            l:=GOTONEXTSYSTEM(ActSys,MyShipPtr);
  8190.                                         end;
  8191.                                      end else if (MyShipPtr^.Ladung and MASK_LTRUPPS)>0 then with MyPlanetHeader^ do begin
  8192.                                         CHECKPLANET(MyPlanetHeader);
  8193.                                         Bool:=TAKETECH(MyShipPtr^.Owner,MyPlanetHeader^.PFlags and FLAG_CIV_MASK);
  8194.                                         Save.Staatstopf[GETCIVVAR(MyShipPtr^.Owner)]:=
  8195.                                          Save.Staatstopf[GETCIVVAR(MyShipPtr^.Owner)]+(MyPlanetHeader^.XProjectPayed div 5);
  8196.                                         MyPlanetHeader^.XProjectPayed:=round(MyPlanetHeader^.XProjectPayed*0.8);
  8197.                                         AUTOVERHANDLUNG(MyShipPtr^.Owner,PFlags,ActSys,0);
  8198.                                         CHECKPROJECTS(MyPlanetHeader,MyShipPtr^.Owner);
  8199.                                         PFlags:=MyShipPtr^.Owner;
  8200.                                         if (Population<Size*13) or (random(5)=0) then Ethno:=MyShipPtr^.Owner;
  8201.                                         ProjectID:=0;
  8202.                                         MyShipPtr^.Moving:=0;
  8203.                                         if not SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0 then begin
  8204.                                            REFRESHDISPLAY;
  8205.                                            delay(10);
  8206.                                         end;
  8207.                                         exit;
  8208.                                      end else FINDENEMYOBJECT(ActSys,MyShipPtr);
  8209.                                   end else begin
  8210.                                      MyShipPtr^.PosX:=FromX;
  8211.                                      MyShipPtr^.PosY:=FromY;
  8212.                                      MyShipPtr^.Moving:=0;
  8213.                                      if (Save.WarState[CivVar,1] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8214.                                         (Save.WarState[CivVar,2] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8215.                                         (Save.WarState[CivVar,3] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8216.                                         (Save.WarState[CivVar,4] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8217.                                         (Save.WarState[CivVar,5] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8218.                                         (Save.WarState[CivVar,6] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8219.                                         (Save.WarState[CivVar,7] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  8220.                                         (Save.WarState[CivVar,8] in [LEVEL_WAR,LEVEL_COLDWAR])
  8221.                                      then FINDENEMYOBJECT(i,MyShipPtr)
  8222.                                      else l:=GOTONEXTSYSTEM(ActSys,MyShipPtr);
  8223.                                      exit;
  8224.                                   end;
  8225.                                end;
  8226.                             end;
  8227.                TYPE_SHIP:   begin
  8228.                                OtherShipPtr:=ObjPtr;
  8229.                                if (OtherShipPtr^.Owner<>MyShipPtr^.Owner)
  8230.                                and (Save.WarState[CivVar,GETCIVVAR(OtherShipPtr^.Owner)] in [LEVEL_WAR,LEVEL_COLDWAR]) then begin
  8231.                                   if (Save.CivPlayer[ActPlayer]=0)
  8232.                                    and (Save.CivPlayer[GETCIVVAR(OtherShipPtr^.Owner)]<>0) then begin
  8233.                                      MyShipPtr^.PosX:=FromX;
  8234.                                      MyShipPtr^.PosY:=FromY;
  8235.                                      exit;
  8236.                                   end;
  8237.                                   if Save.WarState[CivVar,GETCIVVAR(OtherShipPtr^.Owner)]=LEVEL_COLDWAR then GOTOWAR(MyShipPtr^.Owner,OtherShipPtr^.Owner);
  8238.                                   MyShipPtr^.PosX:=FromX;
  8239.                                   MyShipPtr^.PosY:=FromY;
  8240.                                   delay(20);
  8241.                                   if BIGSHIPFIGHT(MyShipPtr,OtherShipPtr,MODE_ONCE,ActSys)=1 then begin
  8242.                                      MyShipPtr^.Moving:=0;
  8243.                                      exit;
  8244.                                   end;
  8245.                                end else begin
  8246.                                   MyShipPtr^.PosX:=FromX;
  8247.                                   MyShipPtr^.PosY:=FromY;
  8248.                                   exit;
  8249.                                end;
  8250.                             end;
  8251.                TYPE_STARGATE: if MyShipPtr^.Target=TARGET_ENEMY_SHIP then
  8252.                                if MyShipPtr^.TargetShip=^SystemHeader[ActSys].FirstShip then begin
  8253.                                  SysID:=MyShipPtr^.Source;
  8254.                                  FADESTARGATE(SysID,ActSys,MyShipPtr);
  8255.                                  if MyShipPtr^.Moving<=0 then
  8256.                                   SystemFlags[ActPlayer,ActSys]:=SystemFlags[ActPlayer,ActSys] or FLAG_KNOWN;
  8257.                                  exit;
  8258.                               end;
  8259.                TYPE_WORMHOLE: DOWORMHANDLING(MyShipPtr);
  8260.                otherwise;
  8261.             end;
  8262.          end;
  8263.          for i:=1 to MAXHOLES do with MyWormHole[i] do for j:=1 to 2 do if System[j]=ActSys then begin
  8264.             if (MyShipPtr^.PosX in [PosX[j]-10..PosX[j]+10]) and
  8265.             (MyShipPtr^.PosY in [PosY[j]-10..PosY[j]+10]) then begin
  8266.                if GETCIVVAR(MyShipPtr^.Owner)>0 then CivKnowledge[GETCIVVAR(MyShipPtr^.Owner)]:=FLAG_KNOWN;
  8267.             end;
  8268.          end;
  8269.          MyShipPtr^.Moving:=MyShipPtr^.Moving-1;
  8270.          if Visible then begin
  8271.             DRAWMOVINGSHIP;
  8272.             if (MyShipPtr^.Moving>=0) and (OldMoving<>MyShipPtr^.Moving) then with MyShipPtr^ do begin
  8273.                s:=intstr(round((Shield+Tactical*3)/ShipData[SType].MaxShield*100))+'%';
  8274.                                         while length(s)<4 do s:='0'+s;
  8275.                s:=intstr(Moving)+'-'+s; while length(s)<7 do s:='0'+s;
  8276.                WRITE(521,293,GETCIVFLAG(ActPlayer),1,MyScreen[1]^,2,s);
  8277.                OldMoving:=Moving;
  8278.             end;
  8279.          end;
  8280.       until MyShipPtr^.Moving<=0;
  8281.       exit;
  8282.    end;
  8283.    repeat
  8284.       CLOCK;
  8285.       delay(1);
  8286.       FromX:=MyShipPtr^.PosX;
  8287.       FromY:=MyShipPtr^.PosY;
  8288.       l:=l+1;
  8289.       if l=15 then begin
  8290.          SetAPen(^MyScreen[1]^.RastPort,0);
  8291.          if (x in [0..480]) and (y in [0..480]) then DRAWRECT(x,y);
  8292.          if (x in [0..505]) and (y in [0..512]) and (MyShipPtr^.SType<>SHIPTYPE_FLEET)
  8293.          then with MyShipPtr^ do begin
  8294.             s:='';
  8295.             if Ladung and MASK_SIEDLER>0 then s:='S';
  8296.             if Ladung and MASK_LTRUPPS>0 then s:=s+'L';
  8297.             if Fracht>0 then s:='W';
  8298.             if SType=21 then s:=s+' '+intstr(round(SQRT((PosX*PosX)+(PosY*PosY))));
  8299.             WRITE(x+2,y+21,MyShipPtr^.Owner,0,MyScreen[1]^,1,s);
  8300.          end;
  8301.       end else if l=30 then begin
  8302.          SetAPen(^MyScreen[1]^.RastPort,MyShipPtr^.Owner);
  8303.          if (x in [0..480]) and (y in [0..480]) then DRAWRECT(x,y);
  8304.          l:=0;
  8305.       end;
  8306.  
  8307.       RawCode:=0;
  8308.       RawCode:=GETRAWCODE;
  8309.  
  8310.       if (LData^ and 64=0) or (RawCode in [29..31,45,47,61..63,76..79]) then begin
  8311.          if (IBase^.MouseX in [0..512])
  8312.          or (RawCode in [29..31,45,47,61..63,76..79]) then begin
  8313.             if FINDOBJECT(ActSys,IBase^.MouseX,IBase^.MouseY,NIL) then begin
  8314.                PLAYSOUND(1,300);
  8315.                case ObjType of
  8316.                   TYPE_PLANET:   PLANETINFO(ActSys);
  8317.                   TYPE_SHIP:     if MyShipPtr^.SType=SHIPTYPE_FLEET then ORBITINFO(MyShipPtr,'Flotte',ActSys,0,0)
  8318.                                  else SHIPINFO(ActSys);
  8319.                   otherwise
  8320.                end
  8321.             end else begin
  8322.                if ((IBase^.MouseX<x) and (RawCode=0)) or (RawCode in [29,45,61,79]) then MyShipPtr^.PosX:=MyShipPtr^.PosX-1;
  8323.                if ((IBase^.MouseX>x+32) and (RawCode=0)) or (RawCode in [31,47,63,78]) then MyShipPtr^.PosX:=MyShipPtr^.PosX+1;
  8324.                if ((IBase^.MouseY<y) and (RawCode=0)) or (RawCode in [61..63,76]) then MyShipPtr^.PosY:=MyShipPtr^.PosY-1;
  8325.                if ((IBase^.MouseY>y+32) and (RawCode=0)) or (Rawcode in [29..31,77]) then MyShipPtr^.PosY:=MyShipPtr^.PosY+1;
  8326.                if (FromX=MyShipPtr^.PosX) and (FromY=MyShipPtr^.PosY) then begin
  8327.                   ObjPtr:=MyShipPtr;
  8328.                   SHIPINFO(ActSys);
  8329.                end else begin
  8330.                   if MyShipPtr^.PosX>50 then MyShipPtr^.PosX:=50; if MyShipPtr^.PosX<-50 then MyShipPtr^.PosX:=-50;
  8331.                   if MyShipPtr^.PosY>50 then MyShipPtr^.PosY:=50; if MyShipPtr^.PosY<-50 then MyShipPtr^.PosY:=-50;
  8332.                   ToX:=256+(MyShipPtr^.PosX+OffsetX)*32;
  8333.                   ToY:=256+(MyShipPtr^.PosY+OffsetY)*32;
  8334.                   if FINDOBJECT(ActSys,ToX+16,ToY+16,MyShipPtr) then case ObjType of
  8335.                      TYPE_PLANET:   begin
  8336.                                        PLAYSOUND(1,300);
  8337.                                        if not PLANETHANDLING(ActSys,MyShipPtr) then begin
  8338.                                           MyShipPtr^.Moving:=0;
  8339.                                           exit;
  8340.                                        end;
  8341.                                     end;
  8342.                      TYPE_SHIP:     begin
  8343.                                        OtherShipPtr:=ObjPtr;
  8344.                                        if OtherShipPtr^.Owner<>MyShipPtr^.Owner then begin
  8345.                                           CivFlag:=OtherShipPtr^.Owner;
  8346.                                           MyShipPtr^.PosX:=FromX;
  8347.                                           MyShipPtr^.PosY:=FromY;
  8348.                                           if STARTBIGSHIPFIGHT(MyShipPtr,OtherShipPtr,MODE_ONCE,ActSys)=1 then begin
  8349.                                              AUTOVERHANDLUNG(ActPlayerFlag,CivFlag,ActSys,0);
  8350.                                              MyShipPtr^.Moving:=0;
  8351.                                              exit;
  8352.                                           end;
  8353.                                           AUTOVERHANDLUNG(ActPlayerFlag,CivFlag,ActSys,0);
  8354.                                        end else if MyShipPtr^.SType<>SHIPTYPE_FLEET then begin
  8355.                                           FleetShipPtr:=OtherShipPtr;
  8356.                                           if OtherShipPtr^.SType<>SHIPTYPE_FLEET then begin
  8357.                                              l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  8358.                                              if l=0 then DisplayBeep(NIL) else begin
  8359.                                                 CopyMemQuick(long(OtherShipPtr),l,sizeof(r_ShipHeader));
  8360.                                                 OtherShipPtr^.SType:=SHIPTYPE_FLEET;
  8361.                                                 OtherShipPtr^.TargetShip:=ptr(l);
  8362.                                                 OtherShipPtr^.TargetShip^.BeforeShip:=OtherShipPtr;
  8363.                                                 OtherShipPtr^.TargetShip^.NextShip:=NIL;
  8364.                                                 OtherShipPtr^.TargetShip^.Flags:=0;
  8365.                                              end;
  8366.                                           end;
  8367.                                           if OtherShipPtr^.TargetShip<>NIL then begin
  8368.                                              OtherShipPtr^.Flags:=0;
  8369.                                              OtherShipPtr:=OtherShipPtr^.TargetShip;
  8370.  
  8371.                                              while (OtherShipPtr^.SType<MyShipPtr^.SType)
  8372.                                              and (OtherShipPtr^.NextShip<>NIL)
  8373.                                               do OtherShipPtr:=OtherShipPtr^.NextShip;
  8374.  
  8375.                                              if OtherShipPtr^.BeforeShip^.SType=SHIPTYPE_FLEET then begin
  8376.                                                 MyShipPtr^.BeforeShip^.NextShip:=MyShipPtr^.NextShip;
  8377.                                                 if MyShipPtr^.NextShip<>NIL then MyShipPtr^.NextShip^.BeforeShip:=MyShipPtr^.BeforeShip;
  8378.                                                 MyShipPtr^.BeforeShip:=OtherShipPtr^.BeforeShip;
  8379.                                                 MyShipPtr^.NextShip:=OtherShipPtr;
  8380.  
  8381.                                                 OtherShipPtr^.BeforeShip^.TargetShip:=MyShipPtr;
  8382.                                                 OtherShipPtr^.BeforeShip:=MyShipPtr;
  8383.                                              end else LINKSHIP(MyShipPtr,OtherShipPtr,1);
  8384.                                              DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  8385.                                           end;
  8386.                                           MyShipPtr:=FleetShipPtr;
  8387.                                        end else begin
  8388.                                           MyShipPtr^.PosX:=FromX;
  8389.                                           MyShipPtr^.PosY:=FromY;
  8390.                                           PLAYSOUND(1,600);
  8391.                                        end;
  8392.                                     end;
  8393.                      TYPE_STARGATE: begin
  8394.                                        DRAWSTARS(MODE_STARGATE,ActPlayer);
  8395.                                        SysID:=0;
  8396.                                        repeat
  8397.                                           delay(RDELAY);
  8398.                                           if (LData^ and 64=0) then begin
  8399.                                              if LastSystem<>0 then
  8400.                                               if SystemHeader[LastSystem].FirstShip.SType=TARGET_STARGATE then
  8401.                                               SysID:=LastSystem;
  8402.                                              PLAYSOUND(1,300);
  8403.                                           end else WRITEGALAXYDATA(0,TARGET_STARGATE);
  8404.                                        until (RData^ and 1024=0) or (SysID<>0);
  8405.                                        if (RData^ and 1024=0) or (SysID=ActSys) then begin
  8406.                                           MyShipPtr^.PosX:=FromX;
  8407.                                           MyShipPtr^.PosY:=FromY;
  8408.                                           PLAYSOUND(1,300);
  8409.                                           DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  8410.                                        end;
  8411.                                        if not (SysID in [0,ActSys]) then begin
  8412.                                           x:=ToX; y:=ToY;
  8413.                                           FADESTARGATE(SysID,ActSys,MyShipPtr);
  8414.                                           exit;
  8415.                                        end;
  8416.                                     end;
  8417.                      TYPE_WORMHOLE: DOWORMHANDLING(MyShipPtr);
  8418.                      otherwise begin
  8419.                         writeln('FINDOBJ-Err,TerraShip');
  8420.                         DisplayBeep(NIL);
  8421.                      end;
  8422.                   end else if (SystemHeader[ActSys].FirstShip.SType<>TARGET_STARGATE)
  8423.                   and (MyShipPtr^.SType<>SHIPTYPE_FLEET)
  8424.                   and ((Year+(MyShipPtr^.PosX*MyShipPtr^.PosY)) mod 335=0) then begin
  8425.                      DRAWMOVINGSHIP;
  8426.  
  8427.  
  8428.                      if not WORMHOLE(MyShipPtr) then begin
  8429.                         MyShipPtr^.Owner:=0;
  8430.                         exit;
  8431.                      end;
  8432.                   end else DRAWMOVINGSHIP;
  8433.                   if MyShipPtr^.Moving>0 then MyShipPtr^.Moving:=MyShipPtr^.Moving-1;
  8434.                   if (MyShipPtr^.PosX in [-3..2]) and (MyShipPtr^.PosY in [-3..2]) then begin
  8435.                      FromX:=MyShipPtr^.PosX;
  8436.                      FromY:=MyShipPtr^.PosY;
  8437.                      MyShipPtr^.Owner:=0;
  8438.                      EXPLODE(ActSys,MyShipPtr);
  8439.                      if MyShipPtr^.SType=SHIPTYPE_FLEET then KILLFLEET(MyShipPtr)
  8440.                      else if MyShipPtr^.SType in [17..24] then STARDESASTER(ActSys,MyShipPtr);
  8441.                      exit;
  8442.                    end;
  8443.                 end;
  8444.              end;
  8445.          end else if (RawCode=0) and (IBase^.MouseX in [522..629])
  8446.          and (IBase^.MouseY in [9..117]) then begin
  8447.             OffsetX:=576-IBase^.MouseX; OffsetY:=63-IBase^.MouseY;
  8448.             DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  8449.          end;
  8450.       end else if (RData^ and 1024=0) then begin
  8451.          if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [9..117]) then begin
  8452.             if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [9..29]) then
  8453.              if OffsetY<42 then OffsetY:=OffsetY+2;
  8454.             if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [97..117]) then
  8455.              if OffsetY>-42 then OffsetY:=OffsetY-2;
  8456.             if (IBase^.MouseX in [518..538]) and (IBase^.MouseY in [9..117]) then
  8457.              if OffsetX<42 then OffsetX:=OffsetX+2;
  8458.             if (IBase^.MouseX in [614..634]) and (IBase^.MouseY in [9..117]) then
  8459.              if OffsetX>-42 then OffsetX:=OffsetX-2;
  8460.             DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  8461.          end else begin
  8462.             PLAYSOUND(1,300);
  8463.             if FINDOBJECT(ActSys,x+16,y+16,NIL) then begin
  8464.                case ObjType of
  8465.                   TYPE_SHIP: SYSTEMINFO(ActSys);
  8466.                   otherwise;
  8467.                end;
  8468.             end;
  8469.          end;
  8470.  
  8471.       end;
  8472.       if (MyShipPtr^.PosX>60) or (MyShipPtr^.PosY>60) then begin
  8473.          ObjPtr:=MyShipPtr;
  8474.          SYSTEMINFO(ActSys);
  8475.       end;
  8476.       if (MyShipPtr^.Moving>=0) and (OldMoving<>MyShipPtr^.Moving) then with MyShipPtr^ do begin
  8477.          if SType=SHIPTYPE_FLEET then s:='----' else begin
  8478.             s:=intstr(round((Shield+Tactical*3)/ShipData[SType].MaxShield*100))+'%';
  8479.             while length(s)<4 do s:='0'+s;
  8480.          end;
  8481.          s:=intstr(Moving)+'-'+s; while length(s)<7 do s:='0'+s;
  8482.          OldMoving:=Moving;
  8483.          WRITE(521,293,GETCIVFLAG(ActPlayer),1,MyScreen[1]^,2,s);
  8484.       end;
  8485.       x:=256+(MyShipPtr^.PosX+OffsetX)*32;
  8486.       y:=256+(MyShipPtr^.PosY+OffsetY)*32;
  8487.       CLEARINTUITION;
  8488.    until (MyShipPtr^.Moving<=0) or (MyShipPtr^.Target=TARGET_POSITION) or (MyShipPtr^.Owner=0);
  8489.    RECT(MyScreen[1]^,0,520,291,632,308);
  8490. end;   { MOVESHIP }
  8491.  
  8492.  
  8493.  
  8494. procedure SYSTEMINFO;
  8495.  
  8496. var i                           :integer;
  8497. var l                           :long;
  8498. var SysID                       :byte;
  8499. var x,y                         :word;
  8500. var b                           :boolean;
  8501. var MyShipPtr,UseShipPtr        :^r_ShipHeader;
  8502. var FleetUsed                   :boolean;
  8503.  
  8504.  
  8505. begin
  8506.    b:=false;
  8507.    MyShipPtr:=ObjPtr;
  8508.    if Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]=0 then exit;
  8509.    UseShipPtr:=MyShipPtr;
  8510.    if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  8511.       FleetUsed:=true;
  8512.       MyShipPtr:=MyShipPtr^.TargetShip;
  8513.    end else FleetUsed:=false;
  8514.    MAKEBORDER(MyScreen[1]^,194,119,316,232,12,6,1);
  8515.    for i:=1 to 5 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  8516.    WRITE(256,124,0,16,MyScreen[1]^,4,'Sterne');
  8517.    WRITE(256,146,0,16,MyScreen[1]^,4,'Sprengen');
  8518.    if UseShipPtr^.Target=TARGET_POSITION then WRITE(256,168,0,16,MyScreen[1]^,4,'Ablösen')
  8519.    else WRITE(256,168,0,16,MyScreen[1]^,4,'Position');
  8520.    if MyShipPtr^.SType<>21 then WRITE(256,190,0,16,MyScreen[1]^,4,'Bewässern')
  8521.      else WRITE(256,190,0,16,MyScreen[1]^,4,'Stargate');
  8522.    WRITE(256,212,0,16,MyScreen[1]^,4,'Warten');
  8523.    repeat
  8524.       delay(RDELAY);
  8525.       if (LData^ and 64=0) then begin
  8526.          if IBase^.MouseX in [194..316] then begin
  8527.             if IBase^.MouseY in [122..142] then begin
  8528.                KLICKGAD(198,122);
  8529.                b:=true;
  8530.                DRAWSTARS(MODE_REDRAW,ActPlayer);
  8531.                SysID:=0;
  8532.                repeat
  8533.                   delay(RDELAY);
  8534.                   if (LData^ and 64=0) then begin
  8535.                      SysID:=LastSystem;
  8536.                      PLAYSOUND(1,300);
  8537.                   end else WRITEGALAXYDATA(ActSys,ShipData[MyShipPtr^.SType].MaxMove);
  8538.                until (RData^ and 1024=0) or (SysID<>0);
  8539.                if (RData^ and 1024=0) then PLAYSOUND(1,300);
  8540.                if (SysID in [1..MAXSYSTEMS]) and (SysID<>ActSys) then begin
  8541.                   with SystemHeader[SysID] do if Planets=0 then CREATENEWSYSTEM(SysID,1);
  8542.                   MyShipPtr^.Target:=SysID;
  8543.                   MyShipPtr^.Source:=ActSys;
  8544.                   l:=abs(SystemX[ActSys]-SystemX[SysID]) + abs(SystemY[ActSys]-SystemY[SysID]);
  8545.                   l:=-(l div ShipData[MyShipPtr^.SType].MaxMove)-1;
  8546.                   if l<-127 then l:=-127;
  8547.                   MyShipPtr^.Moving:=l;
  8548.                   if not FleetUsed then LINKSHIP(MyShipPtr,^SystemHeader[SysID].FirstShip,1)
  8549.                   else begin
  8550.                      MyShipPtr^.BeforeShip^.Moving:=MyShipPtr^.Moving;
  8551.                      MyShipPtr^.BeforeShip^.Target:=MyShipPtr^.Target;
  8552.                      MyShipPtr^.BeforeShip^.Source:=MyShipPtr^.Source;
  8553.                      LINKSHIP(MyShipPtr^.BeforeShip,^SystemHeader[SysID].FirstShip,1);
  8554.                      MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  8555.                   end;
  8556.                end;
  8557.                DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  8558.             end else if IBase^.MouseY in [144..164] then begin
  8559.                KLICKGAD(198,144);
  8560.                b:=true;
  8561.                RECT(MyScreen[1]^,0,194,119,316,234);
  8562.                REFRESHDISPLAY;
  8563.                x:=256+(UseShipPtr^.PosX+OffsetX)*32;
  8564.                y:=256+(UseShipPtr^.PosY+OffsetY)*32;
  8565.                PLAYSOUND(2,1100);
  8566.                if (x in [0..480]) and (y in [0..480]) then begin
  8567.                   RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  8568.                   for i:=0 to 15 do begin
  8569.                      BltBitMapRastPort(^ImgBitMap4,i*32,0,^MyScreen[1]^.RastPort,x,y,31,31,192);
  8570.                      delay(5);
  8571.                   end;
  8572.                   RECT(MyScreen[1]^,0,x,y,x+31,y+31);
  8573.                end;
  8574.                delay(10);
  8575.                UseShipPtr^.Owner:=0;
  8576.                UseShipPtr^.SType:=8;
  8577.                UseShipPtr^.Moving:=0;
  8578.                if FleetUsed then begin
  8579.                   repeat
  8580.                      MyShipPtr^.Owner:=0;
  8581.                      MyShipPtr:=MyShipPtr^.NextShip;
  8582.                   until MyShipPtr=NIL;
  8583.                end;
  8584.                DMACON_WRITE^:=$0003;
  8585.            end else if IBase^.MouseY in [166..186] then begin
  8586.                KLICKGAD(198,166);
  8587.                b:=true;
  8588.                if UseShipPtr^.Target=TARGET_POSITION then begin
  8589.                   RECT(MyScreen[1]^,0,194,119,316,234);
  8590.                   REFRESHDISPLAY;
  8591.                   UseShipPtr^.Target:=ActSys;
  8592.                   if UseShipPtr^.Moving>0 then MOVESHIP(ActSys,UseShipPtr,false);
  8593.                end else UseShipPtr^.Target:=TARGET_POSITION;
  8594.             end else if IBase^.MouseY in [188..208] then begin
  8595.                KLICKGAD(198,188);
  8596.                b:=true;
  8597.                if MyShipPtr^.SType=21 then with SystemHeader[ActSys] do begin
  8598.                   if round(SQRT((MyShipPtr^.PosX*MyShipPtr^.PosX)+(MyShipPtr^.PosY*MyShipPtr^.PosY)))>=10 then begin
  8599.                      MAKEBORDER(MyScreen[1]^,70,115,440,200,12,6,0);
  8600.                      WRITE(256,125,ActPlayerFlag,16,MyScreen[1]^,4,'Bahnradius für Stargate' );
  8601.                      WRITE(256,147,ActPlayerFlag,16,MyScreen[1]^,4,'ist zu groß!');
  8602.                      WRITE(256,169,ActPlayerFlag,16,MyScreen[1]^,4,'Radius muß kleiner 10 sein!');
  8603.                      WAITLOOP(false);
  8604.                      RECT(MyScreen[1]^,0,70,115,440,200);
  8605.                   end else if FirstShip.SType=0 then begin
  8606.                      FirstShip.SType:=TARGET_STARGATE;
  8607.                      FirstShip.PosX:=MyShipPtr^.PosX;
  8608.                      FirstShip.PosY:=MyShipPtr^.PosY;
  8609.                      MyShipPtr^.Owner:=0;
  8610.                      RECT(MyScreen[1]^,0,194,119,316,234);
  8611.                      REFRESHDISPLAY;
  8612.                      delay(15);
  8613.                   end else REQUEST('Stargate ist bereits','installiert!',ActPlayerFlag,ActPlayerFlag)
  8614.                end else with MyShipPtr^ do if Ladung=0
  8615.                   then begin
  8616.                      if not FleetUsed then begin
  8617.                         MyShipPtr^.Flags:=1-MyShipPtr^.Flags;
  8618.                         { SHIPFLAG_NONE <-> SHIPFLAG_WATER }
  8619.                         MyShipPtr^.Moving:=0;
  8620.                      end else REQUEST('Flotten können nicht Bewässern!','Es sind einzelne Schiffe aus der Flotte zu lösen!',ActPlayerFlag,ActPlayerFlag);
  8621.                   end else REQUEST('Das Schiff hat noch Ladung an Bord!','Schiff zuerst entladen!',ActPlayerFlag,ActPlayerFlag);
  8622.             end else if IBase^.MouseY in [210..230] then begin
  8623.                KLICKGAD(198,210);
  8624.                UseShipPtr^.Moving:=0;
  8625.                b:=true;
  8626.             end;
  8627.          end;
  8628.       end;
  8629.       if (RData^ and 1024=0) then begin
  8630.          PLAYSOUND(1,300);
  8631.          b:=true;
  8632.       end;
  8633.    until b;
  8634.    RECT(MyScreen[1]^,0,194,119,316,234);
  8635.    REFRESHDISPLAY;
  8636. end;
  8637.  
  8638.  
  8639.  
  8640. procedure INITMENU;
  8641.  
  8642. var l,ISize     :long;
  8643.  
  8644. begin
  8645.    Screen2:=0;
  8646.    s:=PathStr[8]+'Menu.pal';
  8647.    l:=SETCOLOR(MyScreen[2]^,s);
  8648.    if not IMemID then begin
  8649.       s:=PathStr[8]+'Menu.img';
  8650.       if not DISPLAYIMAGE(s,0,0,640,512,6,MyScreen[2]^,4) then begin
  8651.          DisplayBeep(NIL);
  8652.          exit;
  8653.       end;
  8654.       IMemID:=true;
  8655.       exit;
  8656.    end;
  8657.    DrawImage(^MyScreen[2]^.RastPort,^Img,0,0);
  8658. end;
  8659.  
  8660.  
  8661.  
  8662.  
  8663. procedure OPTIONMENU(Mode :byte);
  8664.  
  8665. var i,j,Player,btx      :byte;
  8666. var Factor              :real;
  8667. var b                   :boolean;
  8668.  
  8669.  
  8670. procedure DRAWGAD(GadID,GadSelect :word);
  8671.  
  8672. var Col1,Col2   :byte;
  8673.  
  8674. begin
  8675.    if GadSelect=1 then begin
  8676.       Col1:=100; Col2:=107;
  8677.    end else begin
  8678.       Col1:=40; Col2:=14;
  8679.    end;
  8680.    MAKEBORDER(MyScreen[2]^,60,GadID,124,GadID+63,Col1,Col2,1);
  8681.    if GadSelect=1 then begin
  8682.       Col1:=40; Col2:=14;
  8683.    end else begin
  8684.       Col1:=100; Col2:=107;
  8685.    end;
  8686.    MAKEBORDER(MyScreen[2]^,150,GadID,214,GadID+63,Col1,Col2,1);
  8687. end;
  8688.  
  8689.  
  8690. procedure CHECKGADS(GadID :byte);
  8691.  
  8692. begin
  8693.    if GadID in [0,7] then begin
  8694.       RECT(MyScreen[2]^,0,542,141,568,310);
  8695.       s:=intstr(Player);
  8696.       WRITE(555,(5-Player)*38+142,40,16,MyScreen[2]^,4,s);
  8697.       if GadID=7 then exit;
  8698.    end;
  8699.    if GadID in [0,6] then begin
  8700.       RECT(MyScreen[2]^,0,447,141,473,310);
  8701.       RECT(MyScreen[2]^,0,410,341,510,360);
  8702.       s:=intstr(Level);
  8703.       WRITE(460,(10-Level)*17+142,40,16,MyScreen[2]^,4,s);
  8704.       case Level of
  8705.          1: s:='Schlaffi';
  8706.          2: s:='Anfänger';
  8707.          3: s:='Kadett';
  8708.          4: s:='Lieutenant';
  8709.          5: s:='Commander';
  8710.          6: s:='1st Cmdr.';
  8711.          7: s:='Captain';
  8712.          8: s:='Admiral';
  8713.          9: s:='Botschafter';
  8714.          otherwise s:='Präsident';
  8715.       end;
  8716.       WRITE(460,343,40,16,MyScreen[2]^,4,s);
  8717.       if GadID=6 then exit;
  8718.    end;
  8719.    if GadID=0 then for i:=1 to 5 do RECT(MyScreen[2]^,0,238,33+i*80,388,52+i*80)
  8720.    else RECT(MyScreen[2]^,0,238,33+GadID*80,388,52+GadID*80);
  8721.    if GadID in [0,1] then begin
  8722.       if Save.PlayMySelf then begin
  8723.          DRAWGAD(80,1);
  8724.          WRITE(240,115,40,1,MyScreen[2]^,4,'Computer');
  8725.       end else begin
  8726.          DRAWGAD(80,2);
  8727.          WRITE(240,115,40,1,MyScreen[2]^,4,'Trekkie');
  8728.       end;
  8729.    end;
  8730.    if GadID in [0,2] then begin
  8731.       if Save.SmallFight then begin
  8732.          DRAWGAD(160,1);
  8733.          WRITE(240,195,40,1,MyScreen[2]^,4,'aus');
  8734.       end else begin
  8735.          DRAWGAD(160,2);
  8736.          WRITE(240,195,40,1,MyScreen[2]^,4,'ein');
  8737.       end;
  8738.    end;
  8739.    if GadID in [0,3] then begin
  8740.       if Save.SmallLand then begin
  8741.          DRAWGAD(240,1);
  8742.          WRITE(240,275,40,1,MyScreen[2]^,4,'Computer');
  8743.       end else begin
  8744.          DRAWGAD(240,2);
  8745.          WRITE(240,275,40,1,MyScreen[2]^,4,'Spieler');
  8746.       end;
  8747.    end;
  8748.    if GadID in [0,4] then begin
  8749.       if Save.NoWorm then begin
  8750.          DRAWGAD(320,1);
  8751.          WRITE(240,355,40,1,MyScreen[2]^,4,'Computer');
  8752.       end else begin
  8753.          DRAWGAD(320,2);
  8754.          WRITE(240,355,40,1,MyScreen[2]^,4,'Spieler');
  8755.       end;
  8756.    end;
  8757.    if GadID in [0,5] then begin
  8758.       if Save.FastMove then begin
  8759.          DRAWGAD(400,1);
  8760.          WRITE(240,435,40,1,MyScreen[2]^,4,'schnell');
  8761.       end else begin
  8762.          DRAWGAD(400,2);
  8763.          WRITE(240,435,40,1,MyScreen[2]^,4,'normal  ');
  8764.       end;
  8765.    end;
  8766. end;
  8767.  
  8768.  
  8769. begin
  8770.    SWITCHDISPLAY;
  8771.    INITMENU;
  8772.    Player:=0;
  8773.    for i:=1 to 7 do if Save.CivPlayer[i]<>0 then Player:=Player+1;
  8774.    WRITE(320,45,40,16,MyScreen[2]^,5,'SPIELOPTIONEN');
  8775.    for i:=1 to 5 do MAKEBORDER(MyScreen[2]^,236,32+i*80,390,53+i*80,14,40,1);
  8776.  
  8777.    BltBitMapRastPort(^ImgBitMap8,384,128,^MyScreen[2]^.RastPort, 60,80,64,64,192);
  8778.    BltBitMapRastPort(^ImgBitMap8,448,128,^MyScreen[2]^.RastPort,150,80,64,64,192);
  8779.    WRITE(240,90,40,0,MyScreen[2]^,4,'Spieler');
  8780.  
  8781.    BltBitMapRastPort(^ImgBitMap8,384,128,^MyScreen[2]^.RastPort, 60,160,64,64,192);
  8782.    BltBitMapRastPort(^ImgBitMap8,512,128,^MyScreen[2]^.RastPort,150,160,64,64,192);
  8783.    WRITE(240,170,40,0,MyScreen[2]^,4,'Kampfszenen');
  8784.  
  8785.    BltBitMapRastPort(^ImgBitMap8,384,128,^MyScreen[2]^.RastPort, 60,240,64,64,192);
  8786.    BltBitMapRastPort(^ImgBitMap8,448,128,^MyScreen[2]^.RastPort,150,240,64,64,192);
  8787.    WRITE(240,250,40,0,MyScreen[2]^,4,'Planeten-Attacke');
  8788.  
  8789.    BltBitMapRastPort(^ImgBitMap8,384,128,^MyScreen[2]^.RastPort, 60,320,64,64,192);
  8790.    BltBitMapRastPort(^ImgBitMap8,448,128,^MyScreen[2]^.RastPort,150,320,64,64,192);
  8791.    WRITE(240,330,40,0,MyScreen[2]^,4,'Wurmloch-Flug');
  8792.  
  8793.    BltBitMapRastPort(^ImgBitMap8,576,128,^MyScreen[2]^.RastPort, 60,400,64,64,192);
  8794.    BltBitMapRastPort(^ImgBitMap8,512,128,^MyScreen[2]^.RastPort,150,400,64,64,192);
  8795.  
  8796.    WRITE(240,410,40,0,MyScreen[2]^,4,'Schiffsbewegungen');
  8797.  
  8798.    WRITE(460,100,40,16,MyScreen[2]^,4,'Level');
  8799.    if Mode=1 then begin
  8800.       WRITE(455,120,40,0,MyScreen[2]^,2,'I');
  8801.       WRITE(455,320,40,0,MyScreen[2]^,2,'J');
  8802.    end;
  8803.    MAKEBORDER(MyScreen[2]^,445,139,475,312,14,40,1);
  8804.    MAKEBORDER(MyScreen[2]^,407,339,513,362,14,40,1);
  8805.  
  8806.    WRITE(555,100,40,16,MyScreen[2]^,4,'Spieler');
  8807.    if Mode=1 then begin
  8808.       WRITE(550,120,40,0,MyScreen[2]^,2,'I');
  8809.       WRITE(550,320,40,0,MyScreen[2]^,2,'J');
  8810.    end;
  8811.    MAKEBORDER(MyScreen[2]^,540,139,570,312,14,40,1);
  8812.  
  8813.    CHECKGADS(0);
  8814.  
  8815.    ScreenToFront(MyScreen[2]);
  8816.    repeat
  8817.       delay(RDELAY);
  8818.       if (LData^ and 64=0) then begin
  8819.          PLAYSOUND(1,300);
  8820.          if (Mode=1) and (IBase^.MouseX in [550..580]) and (IBase^.MouseY in [120..330]) then begin
  8821.             if (IBase^.MouseY in [120..140]) and (Player<5) then Player:=Player+1;
  8822.             if (IBase^.MouseY in [310..330]) and (Player>1) then Player:=Player-1;
  8823.             CHECKGADS(7);
  8824.          end else if (Mode=1) and (IBase^.MouseX in [455..485]) and (IBase^.MouseY in [120..330]) then begin
  8825.             if (IBase^.MouseY in [120..140]) and (Level<10) then Level:=Level+1;
  8826.             if (IBase^.MouseY in [310..330]) and (Level>1) then Level:=Level-1;
  8827.             CHECKGADS(6);
  8828.          end else begin
  8829.             if IBase^.MouseY in [80..144] then begin
  8830.                if IBase^.MouseX in [60..124] then Save.PlayMySelf:=true
  8831.                else if IBase^.MouseX in [150..214] then Save.PlayMySelf:=false;
  8832.                CHECKGADS(1);
  8833.             end;
  8834.  
  8835.             if IBase^.MouseY in [160..224] then begin
  8836.                if IBase^.MouseX in [60..124] then Save.SmallFight:=true
  8837.                else if IBase^.MouseX in [150..214] then Save.SmallFight:=false;
  8838.                CHECKGADS(2);
  8839.             end;
  8840.  
  8841.             if IBase^.MouseY in [240..304] then begin
  8842.                if IBase^.MouseX in [60..124] then Save.SmallLand:=true
  8843.                else if IBase^.MouseX in [150..214] then Save.SmallLand:=false;
  8844.                CHECKGADS(3);
  8845.             end;
  8846.  
  8847.             if IBase^.MouseY in [320..384] then begin
  8848.                if IBase^.MouseX in [60..124] then Save.NoWorm:=true
  8849.                else if IBase^.MouseX in [150..214] then Save.NoWorm:=false;
  8850.                CHECKGADS(4);
  8851.             end;
  8852.  
  8853.             if IBase^.MouseY in [400..464] then begin
  8854.                if IBase^.MouseX in [60..124] then Save.FastMove:=true
  8855.                else if IBase^.MouseX in [150..214] then Save.FastMove:=false;
  8856.                CHECKGADS(5);
  8857.             end;
  8858.          end;
  8859.          delay(10);
  8860.       end;
  8861.    until (RData^ and 1024=0);
  8862.    PLAYSOUND(1,300);
  8863.    ScreenToFront(XScreen);
  8864.    if (Player>1) or (Save.CivPlayer[1]=0) then Multiplayer:=true else Multiplayer:=false;
  8865.  
  8866.    if (Mode=1) and (Player=1) then Save.CivPlayer[1]:=1;
  8867.    if (Player>1) and (Mode=1) then begin
  8868.       repeat
  8869.          i:=succ(random(MAXSYSTEMS));
  8870.       until i>1;
  8871.       exchange(Save.SystemName[1],Save.SystemName[i]);
  8872.       for i:=1 to Player do begin
  8873.          SWITCHDISPLAY;
  8874.          INITMENU;
  8875.          s:='Spieler '+intstr(i)+' bitte eine Zivilisation auswählen!';
  8876.          WRITE(320,50,40,16,MyScreen[2]^,4,s);
  8877.          if i=1 then begin
  8878.             btx:=1;
  8879.             Save.CivPlayer[1]:=0;
  8880.          end else btx:=7;
  8881.          for j:=1 to btx do begin
  8882.             MAKEBORDER(MyScreen[2]^,100,j*50+50,540,j*50+80,14,40,0);
  8883.             if Save.CivPlayer[j]=0 then s:=GETCIVNAME(j) else s:='Spieler '+intstr(Save.CivPlayer[j]);
  8884.             WRITE(320,j*50+58,40,16,MyScreen[2]^,4,s);
  8885.          end;
  8886.          b:=false;
  8887.          ScreenToFront(MyScreen[2]);
  8888.          repeat
  8889.             delay(RDELAY);
  8890.             if (LData^ and 64=0) and (IBase^.MouseX in [100..540]) then begin
  8891.                for j:=1 to btx do
  8892.                 if (IBase^.MouseY in [j*50+50..j*50+80]) and (Save.CivPlayer[j]=0)
  8893.                 then begin
  8894.                   b:=true;
  8895.                   Save.CivPlayer[j]:=i;
  8896.                   CLICKRECT(MyScreen[2]^,100,j*50+50,540,j*50+80,40);
  8897.                   PLAYERJINGLE(j);
  8898.                end;
  8899.             end;
  8900.          until b;
  8901.          for j:=1 to MAXCIVS do
  8902.           if (Save.CivPlayer[i]=Save.CivPlayer[j]) and (i<>j)
  8903.           then Save.CivPlayer[j]:=0;
  8904.          delay(20);
  8905.       end;
  8906.       SWITCHDISPLAY;
  8907.       INITMENU;
  8908.       WRITE(320,100,40,16,MyScreen[2]^,4,'Mit wieviel Heimatplaneten soll begonnen werden?');
  8909.       for i:=1 to 5 do begin
  8910.          MAKEBORDER(MyScreen[2]^,i*88+35,200,i*88+75,240,14,40,0);
  8911.          s:=intstr(i);
  8912.          WRITE(i*88+55,213,40,16,MyScreen[2]^,4,s);
  8913.       end;
  8914.       ScreenToFront(MyScreen[2]);
  8915.       Homeplanets:=0;
  8916.       repeat
  8917.          delay(RDELAY);
  8918.          if (LData^ and 64=0) and (IBase^.MouseY in [200..240]) then
  8919.           Homeplanets:=(IBase^.MouseX-35) div 88;
  8920.       until Homeplanets in [1..5];
  8921.       CLICKRECT(MyScreen[2]^,Homeplanets*88+35,200,Homeplanets*88+75,240,40);
  8922.       delay(20);
  8923.       SWITCHDISPLAY;
  8924.    end;
  8925.    if Mode=1 then begin
  8926.       if Level<=5 then begin
  8927.          Factor:=1+((Level-5)*0.055);     {78%..100}
  8928.          for j:=1 to MAXCIVS do if Save.CivPlayer[j]<>0 then for i:=1 to 42 do begin
  8929.             Save.TechCosts[j,i]:=round(Save.TechCosts[j,i]*Factor);
  8930.             Save.ProjectCosts[j,i]:=round(Save.ProjectCosts[j,i]*Factor);
  8931.          end;
  8932.       end else begin
  8933.          Factor:=1+((5-Level)*0.066);
  8934.          for j:=1 to MAXCIVS do if Save.CivPlayer[j]=0 then for i:=1 to 42 do begin
  8935.             Save.TechCosts[j,i]:=round(Save.TechCosts[j,i]*Factor);
  8936.             Save.ProjectCosts[j,i]:=round(Save.ProjectCosts[j,i]*Factor);
  8937.          end;
  8938.       end;
  8939.    end;
  8940. end;
  8941.  
  8942.  
  8943.  
  8944. procedure FREESYSTEMMEMORY;
  8945.  
  8946. var MyPlanetHeader              :^r_PlanetHeader;
  8947. var ActShipPtr,FleetShipPtr     :^r_ShipHeader;
  8948. var i,j                         :integer;
  8949. var l,MemCtr                    :long;
  8950.  
  8951. begin
  8952.    for i:=1 to MAXSYSTEMS do with SystemHeader[i] do if PlanetMemA>0 then begin
  8953.       for j:=1 to SystemHeader[i].Planets do begin
  8954.          MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  8955.          if MyPlanetHeader^.ProjectPtr<>NIL then FreeMem(long(MyPlanetHeader^.ProjectPtr),sizeof(ByteArr42));
  8956.          if MyPlanetHeader^.FirstShip.NextShip<>NIL then begin
  8957.             ActShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  8958.  
  8959.             if (ActShipPtr^.SType=SHIPTYPE_FLEET)
  8960.             and (ActShipPtr^.TargetShip<>NIL) then begin
  8961.                FleetShipPtr:=ActShipPtr^.TargetShip;
  8962.                repeat
  8963.                   l:=long(FleetShipPtr);
  8964.                   FleetShipPtr:=FleetShipPtr^.NextShip;
  8965.                   FreeMem(l,sizeof(r_ShipHeader));
  8966.                until FleetShipPtr=NIL;
  8967.             end;
  8968.  
  8969.             repeat
  8970.                l:=long(ActShipPtr);
  8971.                ActShipPtr:=ActShipPtr^.NextShip;
  8972.                FreeMem(l,sizeof(r_ShipHeader));
  8973.             until ActShipPtr=NIL;
  8974.          end;
  8975.       end;
  8976.       FreeMem(PlanetMemA,Planets*sizeof(r_PlanetHeader));
  8977.    end;
  8978. end;
  8979.  
  8980.  
  8981.  
  8982. function DISKMENU(Auto :byte):boolean;
  8983.  
  8984. const ACTVERSION=$0004;
  8985. const MODE_SYSTEM=1;
  8986. const MODE_PLANET=2;
  8987.  
  8988. var p                   :ptr;
  8989. var i,j,k               :integer;
  8990. var l                   :long;
  8991. var b                   :boolean;
  8992. var PlanetHeader        :^r_PlanetHeader;
  8993.  
  8994.  
  8995.  
  8996. procedure DECODEDATA;
  8997.  
  8998. var i   :byte;
  8999.  
  9000. begin
  9001.    for i:=1 to MAXCIVS do with Save do
  9002.     Staatstopf[i]:=((Staatstopf[i] xor $FA5375AF)-$13605185) xor $17031973
  9003. end;
  9004.  
  9005.  
  9006.  
  9007. procedure LOADSHIPS(ShipPtr :ptr);
  9008.  
  9009. var ActShipPtr,BeforeShipPtr,
  9010.     FleetShipPtr,BFleetShipPtr  :^r_ShipHeader;
  9011. var l                           :long;
  9012. var FirstFShip                  :boolean;
  9013.  
  9014. begin
  9015.    BeforeShipPtr:=ShipPtr;
  9016.    ActShipPtr:=BeforeShipPtr^.NextShip;
  9017.    while ActShipPtr<>NIL do begin
  9018.       l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  9019.       if l=0 then begin
  9020.          BeforeShipPtr^.NextShip:=NIL;
  9021.          ActShipPtr:=NIL;
  9022.          exit;
  9023.       end;
  9024.       ActShipPtr:=ptr(l);
  9025.       l:=DosRead(FHandle,ActShipPtr,sizeof(r_ShipHeader));
  9026.       BeforeShipPtr^.NextShip:=ActShipPtr;
  9027.       ActShipPtr^.BeforeShip:=BeforeShipPtr;
  9028.       BeforeShipPtr:=ActShipPtr;
  9029.       if (ActShipPtr^.SType=SHIPTYPE_FLEET)
  9030.       and (ActShipPtr^.TargetShip<>NIL) then begin
  9031.          FirstFShip:=true;
  9032.          repeat
  9033.             l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  9034.             if l=0 then begin
  9035.                ActShipPtr^.TargetShip:=NIL;
  9036.                ActShipPtr^.SType:=8;
  9037.                exit;
  9038.             end;
  9039.             FleetShipPtr:=ptr(l);
  9040.             l:=DosRead(FHandle,FleetShipPtr,sizeof(r_ShipHeader));
  9041.             if FirstFShip then begin
  9042.                FleetShipPtr^.BeforeShip:=ActShipPtr;
  9043.                ActShipPtr^.TargetShip:=FleetShipPtr;
  9044.             end else begin
  9045.                BFleetShipPtr^.NextShip:=FleetShipPtr;
  9046.                FleetShipPtr^.BeforeShip:=BFleetShipPtr;
  9047.             end;
  9048.             BFleetShipPtr:=FleetShipPtr;
  9049.             FleetShipPtr:=FleetShipPtr^.NextShip;
  9050.             FirstFShip:=false;
  9051.          until FleetShipPtr=NIL;
  9052.       end;
  9053.       ActShipPtr:=ActShipPtr^.NextShip;
  9054.    end;
  9055. end;
  9056.  
  9057.  
  9058.  
  9059. procedure SAVESHIPS(ShipPtr :ptr);
  9060.  
  9061. var ActShipPtr,FleetShipPtr     :^r_ShipHeader;
  9062. var l                           :long;
  9063.  
  9064. begin
  9065.    ActShipPtr:=ShipPtr;
  9066.    ActShipPtr:=ActShipPtr^.NextShip;
  9067.    repeat
  9068.       p:=ActShipPtr;
  9069.       l:=DosWrite(FHandle,p,sizeof(r_ShipHeader));
  9070.       if (ActShipPtr^.SType=SHIPTYPE_FLEET)
  9071.       and (ActShipPtr^.TargetShip<>NIL) then begin
  9072.          FleetShipPtr:=ActShipPtr^.TargetShip;
  9073.          repeat
  9074.             p:=FleetShipPtr;
  9075.             l:=DosWrite(FHandle,p,sizeof(r_ShipHeader));
  9076.             FleetShipPtr:=FleetShipPtr^.NextShip;
  9077.          until FleetShipPtr=NIL;
  9078.       end;
  9079.       ActShipPtr:=ActShipPtr^.NextShip;
  9080.    until ActShipPtr=NIL;
  9081. end;
  9082.  
  9083.  
  9084.  
  9085. function GETSAVENAME(Title :str):string;
  9086.  
  9087. var ID                  :array [1..6] of string;
  9088. var Y,Version           :long;
  9089. var Lev,i,j,jbef        :byte;
  9090.  
  9091. begin
  9092.    GETSAVENAME:='';
  9093.    s:=PathStr[9]+'IMPT.ID';
  9094.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  9095.    if FHandle=0 then exit else DosClose(FHandle);
  9096.    for i:=1 to 6 do begin
  9097.       ID[i]:='';
  9098.       repeat
  9099.          s:=PathStr[9]+'IMPTST.'+intstr(i);
  9100.          FHandle:=DosOpen(s,MODE_OLDFILE);
  9101.          if FHandle=0 then ID[i]:='leer' else begin
  9102.             l:=DosRead(FHandle,^Version,4);
  9103.             if Version=ACTVERSION then begin
  9104.                l:=DosRead(FHandle,^Y,4);
  9105.                l:=DosRead(FHandle,^Lev,1);
  9106.                ID[i]:='Jahr: '+intstr(Y)+'     Level: '+intstr(Lev);
  9107.                DosClose(FHandle);
  9108.             end else begin
  9109.                DosClose(FHandle);
  9110.                j:=DeleteFile(s);
  9111.             end;
  9112.          end;
  9113.       until ID[i]<>'';
  9114.    end;
  9115.    MAKEBORDER(MyScreen[1]^,100, 80,410,270,12,6,2);
  9116.    MAKEBORDER(MyScreen[1]^,110,110,400,225,6,12,0);
  9117.    MAKEBORDER(MyScreen[1]^,110,235,400,260,6,12,0);
  9118.    WRITE(255,87,ActPlayerFlag,80,MyScreen[1]^,4,Title);
  9119.    for i:=1 to 6 do WRITE(120,97+i*18,ActPlayerFlag,0,MyScreen[1]^,4,ID[i]);
  9120.    jbef:=0;
  9121.    repeat
  9122.       j:=(IBase^.MouseY-97) div 18;
  9123.       if (i<>j) and (j in [1..6]) then begin
  9124.          if jbef<>j then for i:=1 to 6 do if i=j then begin
  9125.             WRITE(120,97+i*18,12,0,MyScreen[1]^,4,ID[i]);
  9126.             RECT(MyScreen[1]^,0,112,237,398,258);
  9127.             WRITE(120,240,12,1,MyScreen[1]^,4,ID[i]);
  9128.             jbef:=j;
  9129.          end else WRITE(120,97+i*18,ActPlayerFlag,0,MyScreen[1]^,4,ID[i]);
  9130.       end;
  9131.    until (j in [1..6]) and (LData^ and 64=0);
  9132.    PLAYSOUND(1,300);
  9133.    GETSAVENAME:=PathStr[9]+'IMPTST.'+intstr(j);
  9134. end;
  9135.  
  9136.  
  9137. procedure ENCODEDATA;
  9138.  
  9139. var i   :byte;
  9140.  
  9141. begin
  9142.    for i:=1 to MAXCIVS do with Save do
  9143.     Staatstopf[i]:=((Staatstopf[i] xor $17031973)+$13605185) xor $FA5375AF;
  9144. end;
  9145.  
  9146.  
  9147.  
  9148.  
  9149. procedure NOMEMMESSAGE;
  9150.  
  9151. begin
  9152.    REQUEST('Nicht genug Speicher vorhanden!','Spielstand kann nicht geladen werden!',8,8);
  9153. end;
  9154.  
  9155.  
  9156. begin
  9157.    DISKMENU:=true;
  9158.    MAKEBORDER(MyScreen[1]^,194,119,316,254,12,6,1);
  9159.    for i:=1 to 6 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  9160.    WRITE(255,124,0,16,MyScreen[1]^,4,'Laden');
  9161.    WRITE(255,146,0,16,MyScreen[1]^,4,'Speichern');
  9162.    WRITE(255,168,0,16,MyScreen[1]^,4,'Löschen');
  9163.    WRITE(255,190,0,16,MyScreen[1]^,4,'Optionen');
  9164.    WRITE(255,212,0,16,MyScreen[1]^,4,'Highscore');
  9165.    WRITE(255,234,8,16,MyScreen[1]^,4,'ENDE');
  9166.    b:=false;
  9167.    repeat
  9168.       delay(RDELAY);
  9169.       if (LData^ and 64=0) or (Auto>0) then begin
  9170.          if (IBase^.MouseX in [198..314]) or (Auto>0) then begin
  9171.             if (IBase^.MouseY in [122..142]) or (Auto=2) then begin
  9172.                KLICKGAD(198,122);
  9173.                b:=true;
  9174.                s:=GETSAVENAME('Spielstand laden');
  9175.                if s<>'' then begin
  9176.                   FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  9177.                   if FHandle<>0 then begin
  9178.                      FREESYSTEMMEMORY;
  9179.                      l:=DosRead(FHandle,^l,4);
  9180.                      l:=DosRead(FHandle,^Year,4);
  9181.                      l:=DosRead(FHandle,^Level,1);
  9182.                      l:=DosRead(FHandle,^ActPlayer,1);
  9183.                      for i:=1 to 3 do l:=DosRead(FHandle,^MyWormHole[i],sizeof(r_WormHole));
  9184.                      l:=DosRead(FHandle,^SystemX[1],MAXSYSTEMS*2);
  9185.                      l:=DosRead(FHandle,^SystemY[1],MAXSYSTEMS*2);
  9186.                      l:=DosRead(FHandle,^SystemFlags[1,1],MAXSYSTEMS*MAXCIVS);
  9187.                      l:=DosRead(FHandle,^MaquesShips,4);
  9188.                      for i:=1 to MAXSYSTEMS do begin
  9189.                         l:=DosRead(FHandle,^SystemHeader[i],sizeof(r_SystemHeader));
  9190.                         with SystemHeader[i] do if (PlanetMemA>0) and (Planets>0) then begin
  9191.                            if SystemHeader[i].FirstShip.NextShip<>NIL then LOADSHIPS(^SystemHeader[i].FirstShip);
  9192.                            PlanetMemA:=AllocMem(sizeof(r_PlanetHeader)*Planets,MEMF_CLEAR);
  9193.                            if PlanetMemA=0 then begin
  9194.                               NOMEMMESSAGE;
  9195.                               exit;
  9196.                            end;
  9197.                            l:=DosRead(FHandle,ptr(PlanetMemA),Planets*sizeof(r_PlanetHeader));
  9198.                            for j:=1 to Planets do begin
  9199.                               PlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  9200.                               if PlanetHeader^.ProjectPtr<>NIL then with PlanetHeader^ do begin
  9201.                                  l:=AllocMem(sizeof(ByteArr42),MEMF_CLEAR);
  9202.                                  if l=0 then begin
  9203.                                     for k:=1 to Planets do begin
  9204.                                        if ProjectPtr<>NIL then FreeMem(long(ProjectPtr),sizeof(ByteArr42));
  9205.                                        ProjectPtr:=NIL;
  9206.                                     end;
  9207.                                     NOMEMMESSAGE;
  9208.                                     exit;
  9209.                                  end;
  9210.                                  ProjectPtr:=ptr(l);
  9211.                                  l:=DosRead(FHandle,ProjectPtr,sizeof(ByteArr42));
  9212.                               end;
  9213.                               if PlanetHeader^.FirstShip.NextShip<>NIL then LOADSHIPS(^PlanetHeader^.FirstShip);
  9214.                            end;
  9215.                         end;
  9216.                      end;
  9217.                      l:=DosRead(FHandle,^Save,sizeof(r_Save));
  9218.                      DECODEDATA;
  9219.                      DosClose(FHandle);
  9220.                   end;
  9221.                end;
  9222.                SETWORLDCOLORS;
  9223.                MultiPlayer:=false;
  9224.                for i:=2 to 7 do if Save.CivPlayer[i]<>0 then MultiPlayer:=true;
  9225.                ActPlayerFlag:=GETCIVFLAG(ActPlayer);
  9226.                LastPlayer:=0; Informed:=false;
  9227.                INFORMUSER;
  9228.             end else if (IBase^.MouseY in [144..164]) or (Auto=1) then begin
  9229.                KLICKGAD(198,144);
  9230.                b:=true;
  9231.                s:=GETSAVENAME('Spielstand speichern');
  9232.                if s<>'' then begin
  9233.                   FHandle:=OPENSMOOTH(s,MODE_NEWFILE);
  9234.                   if FHandle<>0 then begin
  9235.                      l:=ACTVERSION;
  9236.                      l:=DosWrite(FHandle,^l,4);
  9237.                      l:=DosWrite(FHandle,^Year,4);
  9238.                      l:=DosWrite(FHandle,^Level,1);
  9239.                      l:=DosWrite(FHandle,^ActPlayer,1);
  9240.                      for i:=1 to 3 do l:=DosWrite(FHandle,^MyWormHole[i],sizeof(r_WormHole));
  9241.                      l:=DosWrite(FHandle,^SystemX[1],MAXSYSTEMS*2);
  9242.                      l:=DosWrite(FHandle,^SystemY[1],MAXSYSTEMS*2);
  9243.                      l:=DosWrite(FHandle,^SystemFlags[1,1],MAXSYSTEMS*MAXCIVS);
  9244.                      l:=DosWrite(FHandle,^MaquesShips,4);
  9245.                      for i:=1 to MAXSYSTEMS do begin
  9246.                         l:=DosWrite(FHandle,^SystemHeader[i],sizeof(r_SystemHeader));
  9247.                         with SystemHeader[i] do if (PlanetMemA>0) and (Planets>0) then begin
  9248.                            if SystemHeader[i].FirstShip.NextShip<>NIL then SAVESHIPS(^SystemHeader[i].FirstShip);
  9249.                            l:=DosWrite(FHandle,ptr(PlanetMemA),Planets*sizeof(r_PlanetHeader));
  9250.                            for j:=1 to Planets do begin
  9251.                               PlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  9252.                               if PlanetHeader^.ProjectPtr<>NIL then l:=DosWrite(FHandle,PlanetHeader^.ProjectPtr,sizeof(ByteArr42));
  9253.                               if PlanetHeader^.FirstShip.NextShip<>NIL then SAVESHIPS(^PlanetHeader^.FirstShip);
  9254.                            end;
  9255.                         end;
  9256.                      end;
  9257.                      ENCODEDATA;
  9258.                      l:=DosWrite(FHandle,^Save,sizeof(r_Save));
  9259.                      DECODEDATA;
  9260.                      DosClose(FHandle);
  9261.                   end else writeln('No Savefile');
  9262.                end;
  9263.             end else if IBase^.MouseY in [166..186] then begin
  9264.                KLICKGAD(198,166);
  9265.                s:=GETSAVENAME('Spielstand LÖSCHEN');
  9266.                if s<>'' then l:=DeleteFile(s);
  9267.                b:=true;
  9268.             end else if IBase^.MouseY in [188..208] then begin
  9269.                KLICKGAD(198,188);
  9270.                OPTIONMENU(0);
  9271.                ScreenToFront(MyScreen[1]);
  9272.             end else if IBase^.MouseY in [210..230] then begin
  9273.                KLICKGAD(198,210);
  9274.                HIGHSCORE
  9275.             end else if IBase^.MouseY in [232..252] then begin
  9276.                KLICKGAD(198,232);
  9277.                DISKMENU:=false;
  9278.                b:=true;
  9279.             end;
  9280.          end;
  9281.       end;
  9282.    until b or (RData^ and 1024=0) or (Auto>0);
  9283.    if (RData^ and 1024=0) then PLAYSOUND(1,300);
  9284.    DRAWSTARS(MODE_REDRAW,ActPlayer);
  9285. end;
  9286.  
  9287.  
  9288.  
  9289. procedure AUTOSHIPTRAVEL;
  9290.  
  9291. var l                                   :long;
  9292. var i,k                                 :integer;
  9293. var MyShipPtr,BAKShipPtr                :^r_ShipHeader;
  9294. var CivVar,CivVar2,SysSteps,iStep       :byte;
  9295. var DconDone,b,Visible                  :boolean;
  9296. var MyPlanetHeader                      :^r_PlanetHeader;
  9297.  
  9298.  
  9299.  
  9300. function GETMYADJ(CivFlag :byte):str;
  9301.  
  9302. begin
  9303.    case CivFlag of
  9304.       FLAG_TERRA:  GETMYADJ:='Terranisches';
  9305.       FLAG_KLEGAN: GETMYADJ:='Klingonisches';
  9306.       FLAG_REMALO: GETMYADJ:='Romulanisches';
  9307.       FLAG_CARDAC: GETMYADJ:='Kardassianisches';
  9308.       FLAG_FERAGI: GETMYADJ:='Ferengi-';
  9309.       FLAG_BAROJA: GETMYADJ:='Bajoranisches';
  9310.       FLAG_VOLKAN: GETMYADJ:='Vulkanisches';
  9311.       FLAG_OTHER:  case Save.WorldFlag of
  9312.                      WFLAG_CEBORC: GETMYADJ:='Borg-';
  9313.                      WFLAG_DCON:   begin
  9314.                                       GETMYADJ:='Tkonianische Schiffe erreichen';
  9315.                                       DconDone:=true;
  9316.                                    end;
  9317.                      WFLAG_JAHADR: GETMYADJ:='Jem´Hadar-';
  9318.                      otherwise GETMYADJ:=GETMYADJ(Save.WorldFlag);
  9319.                   end;
  9320.       FLAG_MAQUES: GETMYADJ:='Maquis-';
  9321.       otherwise GETMYADJ:='ERROR!';
  9322.    end;
  9323. end;
  9324.  
  9325.  
  9326.  
  9327. begin
  9328.    DconDone:=false;
  9329.    if Mode=MODE_SHIPS then begin
  9330.       SysSteps:=1;
  9331.       i:=ActSys-1;
  9332.       MyShipPtr:=ShipPtr;
  9333.    end else begin
  9334.       i:=0;
  9335.       SysSteps:=2;
  9336.    end;
  9337.    repeat
  9338.       i:=i+1;
  9339.       for iStep:=1 to SysSteps do begin
  9340.          if Mode=MODE_ALL then MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  9341.          if MyShipPtr<>NIL then repeat
  9342.             CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  9343.             if (MyShipPtr^.SType=SHIPTYPE_FLEET) and (CivVar in [1..MAXCIVS])
  9344.             and ((Save.CivPlayer[CivVar]=0) or Save.PlayMySelf)
  9345.              then KILLFLEET(MyShipPtr);
  9346.             if (MyShipPtr^.SType=SHIPTYPE_FLEET) and (CivVar=0) then KILLFLEET(MyShipPtr);
  9347.             if CivVar in [1..MAXCIVS] then begin
  9348.                b:=false; Visible:=false;
  9349.                if CivVar=ActPlayer then b:=true;
  9350.                if b and (Save.CivPlayer[ActPlayer]<>0) then Visible:=true;
  9351.  
  9352.                   {*** Computership mit Playerplanet als Ziel ***}
  9353.                   if (MyShipPtr^.Target>0) and (CivVar in [1..MAXCIVS])
  9354.                   and (Save.CivPlayer[CivVar]=0) then begin
  9355.                      MyPlanetHeader:=ptr(SystemHeader[i].PlanetMemA+sizeof(r_PlanetHeader)*pred(MyShipPtr^.Target));
  9356.                      if GETCIVVAR(MyPlanetHeader^.PFlags) in [1..MAXCIVS] then begin
  9357.                         if  (MyPlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag) then begin
  9358.                            b:=true;
  9359.                            if Save.CivPlayer[GETCIVVAR(MyPlanetHeader^.PFlags)]<>0 then Visible:=true;
  9360.                         end else b:=false;
  9361.                      end;
  9362.                   end;
  9363.                   {*** Computership mit Playership als Ziel ***}
  9364.                   if MyShipPtr^.Target=TARGET_ENEMY_SHIP then FINDENEMYOBJECT(i,MyShipPtr);
  9365.                   if (MyShipPtr^.TargetShip<>NIL) and (CivVar in [1..MAXCIVS])
  9366.                   and not (MyShipPtr^.SType=SHIPTYPE_FLEET) then begin
  9367.                      if (GETCIVVAR(MyShipPtr^.TargetShip^.Owner) in [1..MAXCIVS])
  9368.                      and (Save.CivPlayer[GETCIVVAR(MyShipPtr^.TargetShip^.Owner)]<>0) then begin
  9369.                         if ((GETCIVVAR(MyShipPtr^.TargetShip^.Owner)=ActPlayer)
  9370.                         and (Save.CivPlayer[CivVar]=0)) then begin
  9371.                            b:=true;
  9372.                            if Save.CivPlayer[GETCIVVAR(MyShipPtr^.TargetShip^.Owner)]<>0
  9373.                             then Visible:=true;
  9374.                         end else b:=false;
  9375.                      end
  9376.                   end;
  9377.                   {*** ComputerShip erreicht PlayerSystem ***}
  9378.                   if (CivVar in [1..MAXCIVS]) and
  9379.                   (GETCIVVAR(SystemFlags[1,i]) in [1..MAXCIVS]) then begin
  9380.                      if (Save.CivPlayer[GETCIVVAR(SystemFlags[1,i])]<>0)
  9381.                      and (Save.CivPlayer[CivVar]=0) and (GETCIVVAR(SystemFlags[1,i])=ActPlayer)
  9382.                      then begin
  9383.                         b:=true;
  9384.                         Visible:=true;
  9385.                      end;
  9386.                   end;
  9387.                   if Save.CivPlayer[CivVar]<>0 then Visible:=true;
  9388.                   if Multiplayer and (not (MyShipPtr^.Flags and SHIPFLAG_WATER=0) and not Informed)
  9389.                    then Visible:=false;
  9390.  
  9391.                if b then begin
  9392.                   BAKShipPtr:=MyShipPtr^.BeforeShip;
  9393.                   if (MyShipPtr^.Moving>0) and (MyShipPtr^.Target<>TARGET_POSITION) then begin
  9394.                      if ((Save.CivPlayer[GETCIVVAR(MyShipPtr^.Owner)]=0) or Save.PlayMySelf)
  9395.                      and not ((MyShipPtr^.SType=21) and (SystemHeader[i].FirstShip.SType<>TARGET_STARGATE))
  9396.                      then begin
  9397.                         if (Save.WarState[CivVar,1] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9398.                            (Save.WarState[CivVar,2] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9399.                            (Save.WarState[CivVar,3] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9400.                            (Save.WarState[CivVar,4] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9401.                            (Save.WarState[CivVar,5] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9402.                            (Save.WarState[CivVar,6] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9403.                            (Save.WarState[CivVar,7] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  9404.                            (Save.WarState[CivVar,8] in [LEVEL_WAR,LEVEL_COLDWAR])
  9405.                          then FINDENEMYOBJECT(i,MyShipPtr)
  9406.                         else l:=FINDNEXTPLANET(i,MyShipPtr);
  9407.                      end;
  9408.                      if Visible then INFORMUSER;
  9409.                      if MyShipPtr^.Moving>0 then begin
  9410.                         if Visible then begin
  9411.                            if not ((256+(MyShipPtr^.PosX+OffsetX)*32 in [1..478])
  9412.                            and (256+(MyShipPtr^.PosY+OffsetY)*32 in [1..478]))
  9413.                            or  (Display<>i) then begin
  9414.                               OffsetX:=-MyShipPtr^.PosX-1;
  9415.                               OffsetY:=-MyShipPtr^.PosY-1;
  9416.                               DRAWSYSTEM(MODE_REDRAW,i,MyShipPtr);
  9417.                            end;
  9418.                         end;
  9419.                      end;
  9420.                      CivVar2:=GETCIVVAR(SystemFlags[1,i]);
  9421.                      if CivVar2>0 then begin
  9422.                         if Save.WarState[CivVar,CivVar2]=LEVEL_UNKNOWN then Save.WarState[CivVar,CivVar2]:=LEVEL_PEACE;
  9423.                         if Save.WarState[CivVar2,CivVar]=LEVEL_UNKNOWN then Save.WarState[CivVar2,CivVar]:=LEVEL_PEACE;
  9424.                      end;
  9425.                      MOVESHIP(i,MyShipPtr,Visible);
  9426.                   end else if (MyShipPtr^.Moving<0) and (Mode=MODE_ALL) then begin
  9427.                      MyShipPtr^.Moving:=MyShipPtr^.Moving+1;
  9428.                      if MyShipPtr^.Moving>=0 then begin
  9429.                         CivVar2:=GETCIVVAR(SystemFlags[1,i]);
  9430.                         if CivVar2>0 then begin
  9431.                            if Save.WarState[CivVar,CivVar2]=LEVEL_UNKNOWN then Save.WarState[CivVar,CivVar2]:=LEVEL_PEACE;
  9432.                            if Save.WarState[CivVar2,CivVar]=LEVEL_UNKNOWN then Save.WarState[CivVar2,CivVar]:=LEVEL_PEACE;
  9433.                         end;
  9434.                         SystemFlags[CivVar,i]:=SystemFlags[CivVar,i] or FLAG_KNOWN;
  9435.                         case random(2) of
  9436.                            0: MyShipPtr^.PosX:=-35;
  9437.                            1: MyShipPtr^.PosX:=35;
  9438.                         end;
  9439.                         case random(3) of
  9440.                            0: MyShipPtr^.PosY:=-35;
  9441.                            1: MyShipPtr^.PosY:=35;
  9442.                            2: MyShipPtr^.PosY:=0;
  9443.                         end;
  9444.                         repeat
  9445.                            with MyShipPtr^ do case random(4) of
  9446.                               0: PosX:=PosX+1;
  9447.                               1: PosY:=PosY+1;
  9448.                               2: PosX:=PosX-1;
  9449.                               3: PosY:=PosY-1;
  9450.                            end;
  9451.                         until not FINDOBJECT(i,256+(MyShipPtr^.PosX+OffsetX)*32,256+(MyShipPtr^.PosY+OffsetY)*32,MyShipPtr);
  9452.                         if ((SystemFlags[1,i] and ActPlayerFlag=ActPlayerFlag) or (CivVar=ActPlayer))
  9453.                         and (Save.CivPlayer[ActPlayer]<>0) and not DconDone then begin
  9454.                            INFORMUSER;
  9455.                            MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  9456.                            s:=GETMYADJ(MyShipPtr^.Owner);
  9457.  
  9458.                            if not DconDone then
  9459.                             if MyShipPtr^.SType=SHIPTYPE_FLEET then begin
  9460.                               s[length(s)]:=chr(0);
  9461.                               s:=s+' Flotte erreicht'
  9462.                            end else s:=s+' Schiff erreicht';
  9463.                            WRITE(280,136,MyShipPtr^.Owner,1+16,MyScreen[1]^,4,s);
  9464.                            s:='System '+Save.SystemName[i];
  9465.                            if SystemFlags[1,i] and FLAG_CIV_MASK<>0 then
  9466.                             WRITE(280,163,SystemFlags[1,i] and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s)
  9467.                            else
  9468.                             WRITE(280,163,12,1+16,MyScreen[1]^,4,s);
  9469.                            if MyShipPtr^.Stype<>SHIPTYPE_FLEET then BltBitMapRastPort(^ImgBitMap4,(MyShipPtr^.SType-8)*32,32,^MyScreen[1]^.RastPort,93,140,32,32,192)
  9470.                            else BltBitMapRastPort(^ImgBitMap4,(MyShipPtr^.TargetShip^.SType-8)*32,32,^MyScreen[1]^.RastPort,93,140,32,32,192);
  9471.                            if Save.PlayMySelf then delay(PAUSE);
  9472.                            WAITLOOP(Save.PlayMySelf);
  9473.                            RECT(MyScreen[1]^,0,85,120,425,200);
  9474.                            REFRESHDISPLAY;
  9475.                            if (SystemFlags[1,i] and FLAG_CIV_MASK=FLAG_REMALO) and (Save.CivPlayer[3]=0)
  9476.                             and (MyShipPtr^.Owner<>FLAG_REMALO)
  9477.                             and (Save.WarPower[3]>Save.WarPower[GETCIVVAR(MyShipPtr^.Owner)])
  9478.                             and not (Save.WarState[3,GETCIVVAR(MyShipPtr^.Owner)] in [LEVEL_DIED,LEVEL_ALLIANZ,LEVEL_WAR]) then begin
  9479.                               AUTOVERHANDLUNG(FLAG_REMALO,MyShipPtr^.Owner,ActSys,MODE_TERRITORIUM);
  9480.                               REFRESHDISPLAY;
  9481.                            end;
  9482.                         end;
  9483.                      end;
  9484.                   end;
  9485.                   MyShipPtr:=BAKShipPtr^.NextShip;
  9486.                end;
  9487.             end;
  9488.             if (MyShipPtr<>NIL) and (Mode<>MODE_SHIPS) then MyShipPtr:=MyShipPtr^.NextShip;
  9489.          until (MyShipPtr=NIL) or (Mode=MODE_SHIPS);
  9490.       end;
  9491.    until (i=MAXSYSTEMS) or (Mode=MODE_SHIPS);
  9492.    if (ActSys<>Display) and (Mode<>MODE_SHIPS) then begin
  9493.       if ActSys=0 then DRAWSTARS(MODE_REDRAW,ActPlayer)
  9494.       else DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  9495.    end;
  9496. end;
  9497.  
  9498.  
  9499.  
  9500. procedure ROTATEPLANETS(ActSys :byte);
  9501.  
  9502.  
  9503. var SystemOwn                           :array [1..MAXCIVS] of long;
  9504. var i,j,k                               :integer;
  9505. var l,PMoney                            :long;
  9506. var sin_rot,cos_rot,d                   :real;
  9507. var NewTech                             :array [1..6] of byte;
  9508. var CivVar,PCreativity,PProd,
  9509.     btx,XState,Fight                    :byte;
  9510. var PlanetHeader                        :^r_PlanetHeader;
  9511. var MyShipPtr,ActShipPtr                :^r_ShipHeader;
  9512. var vNS,b,FreeSystem                    :boolean;
  9513. var ActPProjects                        :^ByteArr42;
  9514. var FromX,FromY                         :short;
  9515.  
  9516.  
  9517.  
  9518. function FINDMONEYPLANET(CivFlag,CivVar :byte):byte;
  9519.  
  9520. var MyPlanetHeader                              :^r_PlanetHeader;
  9521. var ActPProject                                 :^ByteArr42;
  9522. var i,j,k,l,Objects,SysID,PID,XProjectID        :Byte;
  9523.  
  9524. begin
  9525.    FINDMONEYPLANET:=0;
  9526.    SysID:=0;   PID:=0;   Objects:=0;   XProjectID:=0;
  9527.    for i:=1 to Save.SYSTEMS do with SystemHeader[i] do if Planets>0 then for j:=1 to Planets do begin
  9528.       MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  9529.       l:=0;
  9530.       with MyPlanetHeader^ do if (PFlags and FLAG_CIV_MASK=CivFlag) then begin
  9531.          ActPProject:=ProjectPtr;
  9532.          l:=ActPProject^[25];
  9533.          for k:=28 to 42 do if ActPProject^[k]>0 then l:=l+1;
  9534.       end;
  9535.       if l>Objects then begin
  9536.          SysID:=i; PID:=j; Objects:=l;
  9537.       end;
  9538.    end;
  9539.    if Objects=0 then exit;
  9540.    if SysID>0 then begin
  9541.       MyPlanetHeader:=ptr(SystemHeader[SysID].PlanetMemA+pred(PID)*sizeof(r_PlanetHeader));
  9542.       ActPProject:=MyPlanetHeader^.ProjectPtr;
  9543.       s:='System: '+Save.SystemName[SysID]+'   Planet: '+MyPlanetHeader^.PName;
  9544.       repeat
  9545.          XProjectID:=succ(random(42));
  9546.       until (XProjectID in [25,28..42]) and (ActPProject^[XProjectID]>0);
  9547.       ActPProject^[XProjectID]:=0;
  9548.       Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]+(Save.ProjectCosts[CivVar,XProjectID] div 29);
  9549.    end;
  9550.    FINDMONEYPLANET:=XProjectID;
  9551. end;
  9552.  
  9553.  
  9554.  
  9555. procedure REFRESHSHIPS(ShipPtr :ptr; SysID,Mode :byte);
  9556.  
  9557. var ActShipPtr,BehindShipPtr,UseShipPtr :^r_ShipHeader;
  9558. var CivVar,CivVar2,i                    :byte;
  9559.  
  9560. begin
  9561.    ActShipPtr:=ShipPtr;
  9562.    if ActShipPtr=NIL then exit;
  9563.    repeat
  9564.       CivVar:=GETCIVVAR(ActShipPtr^.Owner);
  9565.       while not (ActShipPtr^.SType in [8..24,27,SHIPTYPE_FLEET,TARGET_STARGATE])
  9566.       or not (CivVar in [1..MAXCIVS]) or (ActShipPtr^.Owner=0)
  9567.       or ((ActShipPtr^.Age>=200) and (ActShipPtr^.Fracht=0) and (ActShipPtr^.Ladung=0)
  9568.           and (ActShipPtr^.SType<>SHIPTYPE_FLEET)) do begin
  9569.          if (CivVar>0) and (ActShipPtr^.Age>=200) then Verschrottung[CivVar]:=Verschrottung[CivVar]+1;
  9570.          BehindShipPtr:=ActShipPtr^.NextShip;
  9571.  
  9572.          ActShipPtr^.BeforeShip^.NextShip:=ActShipPtr^.NextShip;
  9573.          if ActShipPtr^.NextShip<>NIL then ActShipPtr^.NextShip^.BeforeShip:=ActShipPtr^.BeforeShip;
  9574.  
  9575.          FreeMem(long(ActShipPtr),sizeof(r_ShipHeader));
  9576.          ActShipPtr:=BehindShipPtr;
  9577.          if ActShipPtr=NIL then exit;
  9578.          CivVar:=GETCIVVAR(ActShipPtr^.Owner);
  9579.       end;
  9580.       if ActShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=ActShipPtr^.TargetShip
  9581.       else UseShipPtr:=ActShipPtr;
  9582.       with UseShipPtr^ do begin
  9583.          if Mode=0 then begin
  9584.             ActShipPtr^.PosX:=0; ActShipPtr^.PosY:=0;
  9585.          end;
  9586.          if (Mode=1) and (ActShipPtr^.NextShip<>NIL) then begin
  9587.             CivVar2:=GETCIVVAR(ActShipPtr^.NextShip^.Owner);
  9588.             if (CivVar2>0) and (Moving>0) and (NextShip^.Moving>0) then begin
  9589.                if Save.WarState[CivVar,CivVar2]=LEVEL_UNKNOWN then Save.WarState[CivVar,CivVar2]:=LEVEL_PEACE;
  9590.                if Save.WarState[CivVar2,CivVar]=LEVEL_UNKNOWN then Save.WarState[CivVar2,CivVar]:=LEVEL_PEACE;
  9591.             end;
  9592.          end;
  9593.          if ActShipPtr^.Moving>=0 then begin
  9594.             SystemFlags[CivVar,SysID]:=SystemFlags[CivVar,SysID] or FLAG_KNOWN;
  9595.             for i:=1 to MAXCIVS do if Save.WarState[i,CivVar]=LEVEL_ALLIANZ
  9596.              then SystemFlags[i,SysID]:=SystemFlags[i,SysID] or FLAG_KNOWN;
  9597.             ActShipPtr^.Moving:=ShipData[SType].MaxMove;
  9598.          end;
  9599.          if Shield<ShipData[SType].MaxShield then begin
  9600.             if (Save.CivPlayer[GETCIVVAR(Owner)]<>0) and not Save.PlayMySelf and (Mode=1) then begin
  9601.                Shield:=Shield+Repair;
  9602.                if ActShipPtr^.Moving>0 then ActShipPtr^.Moving:=ActShipPtr^.Moving-Repair;
  9603.             end else begin
  9604.                Shield:=round(Shield*1.3)+1;
  9605.                ActShipPtr^.Moving:=round(ActShipPtr^.Moving*0.77);
  9606.             end;
  9607.          end;
  9608.          if ActShipPtr^.Owner=FLAG_MAQUES then MaquesShips:=MaquesShips+1;
  9609.       end;
  9610.       repeat
  9611.          if UseShipPtr^.Shield>ShipData[UseShipPtr^.SType].MaxShield
  9612.           then UseShipPtr^.Shield:=ShipData[UseShipPtr^.SType].MaxShield;
  9613.          if UseShipPtr^.Age<200 then UseShipPtr^.Age:=UseShipPtr^.Age+1
  9614.          else if UseShipPtr^.Moving>2 then UseShipPtr^.Moving:=ActShipPtr^.Moving div 2;
  9615.          Save.WarPower[CivVar]:=Save.WarPower[CivVar]+round(ShipData[UseShipPtr^.SType].WeaponPower*(UseShipPtr^.Weapon/10+1));
  9616.          Save.Bevölkerung[CivVar]:=Save.Bevölkerung[CivVar]+1;
  9617.          Save.Staatstopf[CivVar]:=Save.Staatstopf[CivVar]-(UseShipPtr^.SType*14);
  9618.          Militärausgaben[CivVar]:=Militärausgaben[CivVar]+(UseShipPtr^.SType*14);
  9619.          if ActShipPtr^.SType=SHIPTYPE_FLEET then UseShipPtr:=UseShipPtr^.NextShip;
  9620.       until (ActShipPtr^.SType<>SHIPTYPE_FLEET) or (UseShipPtr=NIL);
  9621.       if ActShipPtr^.NextShip<>NIL then
  9622.        if ActShipPtr^.NextShip^.BeforeShip<>ActShipPtr then ActShipPtr^.NextShip:=NIL;
  9623.       ActShipPtr:=ActShipPtr^.NextShip;
  9624.    until ActShipPtr=NIL;
  9625. end;
  9626.  
  9627.  
  9628.  
  9629. function GOTONEXTPLANET(ActSys :byte; MyShipPtr :ShipHeader):byte;
  9630.  
  9631. var btx,CivVar,CivFlag          :byte;
  9632. var MyPlanetHeader              :^r_PlanetHeader;
  9633. var OtherShipPtr                :^r_ShipHeader;
  9634. var k,DistOld,DistNew           :integer;
  9635.  
  9636. begin
  9637.    GOTONEXTPLANET:=ActSys;
  9638.    if FINDMAQUESSHIP(ActSys,MyShipPtr) then exit;
  9639.    CivVar:=GETCIVVAR(MyShipPtr^.Owner);
  9640.    CivFlag:=MyShipPtr^.Owner and FLAG_CIV_MASK;
  9641.    btx:=0;
  9642.    DistOld:=10000;
  9643.    for k:=0 to pred(SystemHeader[ActSys].Planets) do begin
  9644.       MyPlanetHeader:=ptr(SystemHeader[ActSys].PlanetMemA+k*sizeof(r_PlanetHeader));
  9645.       OtherShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  9646.       while (OtherShipPtr<>NIL) and (OtherShipPtr^.Owner=0) do OtherShipPtr:=OtherShipPtr^.NextShip;
  9647.       if (MyPlanetHeader^.Class in [CLASS_DESERT,CLASS_HALFEARTH,
  9648.                                     CLASS_EARTH,CLASS_ICE,
  9649.                                     CLASS_STONES,CLASS_WATER])
  9650.        and (MyPlanetHeader^.PFlags=0) and (OtherShipPtr=NIL) then begin
  9651.          DistNew:=round(abs(MyPlanetHeader^.PosX-MyShipPtr^.PosX));
  9652.          if round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY))>DistNew then DistNew:=round(abs(MyPlanetHeader^.PosY-MyShipPtr^.PosY));
  9653.          if DistNew<DistOld then begin
  9654.             DistOld:=DistNew;
  9655.             btx:=k+1;
  9656.             MyShipPtr^.Target:=k+1;
  9657.             MyShipPtr^.Source:=ActSys;
  9658.          end;
  9659.       end;
  9660.    end;
  9661.    if btx<>0 then LINKSHIP(MyShipPtr,^SystemHeader[ActSys].FirstShip,1)
  9662.    else begin
  9663.       SystemHeader[ActSys].State:=SystemHeader[ActSys].State or STATE_ALL_OCC;
  9664.       GOTONEXTPLANET:=GOTONEXTSYSTEM(ActSys,MyShipPtr);
  9665.    end
  9666. end;
  9667.  
  9668.  
  9669.  
  9670. procedure CREATEPANIC(PPtr :ptr; ActSys,PlanetNum :byte);
  9671.  
  9672. var ActPProjects        :^ByteArr42;
  9673. var MyPlanetHeader      :^r_PlanetHeader;
  9674. var OldPlanet           :r_PlanetHeader;
  9675. var TheProject          :short;
  9676. var s1,s2               :string;
  9677. var i,k,NewEthnoFlag    :byte;
  9678. var ModC,ModL,l         :long;
  9679. var PlanetLose,b        :boolean;
  9680. var MyShipPtr           :ShipHeader;
  9681.  
  9682.  
  9683. function SETNEWPLANETOWNER:boolean;
  9684.  
  9685. begin
  9686.    SETNEWPLANETOWNER:=false;
  9687.    with MyPlanetHeader^ do begin
  9688.       NewEthnoFlag:=0;
  9689.       if (PFlags and FLAG_CIV_MASK<>Ethno) then NewEthnoFlag:=Ethno
  9690.       else begin
  9691.          for i:=1 to MAXCIVS-2 do if (Save.ImperatorState[i]>2000)
  9692.          and not (Save.WarState[ActPlayer,i] in [LEVEL_UNKNOWN,LEVEL_DIED]) then
  9693.           NewEthnoFlag:=GETCIVFLAG(i);
  9694.          if NewEthnoFlag<>0 then begin
  9695.             repeat
  9696.                i:=random(MAXCIVS-2)+1;
  9697.             until (Save.ImperatorState[i]>2000)
  9698.             and not (Save.WarState[ActPlayer,i] in [LEVEL_UNKNOWN,LEVEL_DIED]);
  9699.             NewEthnoFlag:=GETCIVFLAG(i);
  9700.          end;
  9701.       end;
  9702.       if NewEthnoFlag=0 then exit;
  9703.       if GetPlanetSys[GETCIVVAR(NewEthnoFlag)]<>0 then exit;
  9704.       GetPlanet[GETCIVVAR(NewEthnoFlag)]:=MyPlanetHeader;
  9705.       GetPlanetSys[GETCIVVAR(NewEthnoFlag)]:=ActSys;
  9706.       OldPlanet:=MyPlanetHeader^;
  9707.       if (Save.CivPlayer[ActPlayer]<>0) then TheProject:=-1;
  9708.       s1:='Schwere ethnische Konflikte ausgebrochen';
  9709.       if PFlags and FLAG_CIV_MASK=ActPlayerFlag then s2:='Unabhängigkeit wurde erklärt';
  9710.       for i:=1 to pred(MAXCIVS) do
  9711.        if Save.WarState[i,GETCIVVAR(Ethno)]=LEVEL_DIED then Save.WarState[i,GETCIVVAR(Ethno)]:=LEVEL_PEACE;
  9712.       if Save.WarState[GETCIVVAR(PFlags),GETCIVVAR(Ethno)]=LEVEL_DIED then Save.WarState[GETCIVVAR(PFlags),GETCIVVAR(Ethno)]:=LEVEL_COLDWAR;
  9713.       PFlags:=NewEthnoFlag;
  9714.       MyShipPtr:=MyPlanetHeader^.FirstShip.NextShip;
  9715.       while MyShipPtr<>NIL do begin
  9716.          if MyShipPtr^.Owner<>0 then MyShipPtr^.Owner:=NewEthnoFlag;
  9717.          MyShipPtr:=MyShipPtr^.NextShip;
  9718.       end;
  9719.       Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+35;
  9720.       if PFlags and FLAG_CIV_MASK=ActPlayerFlag then begin
  9721.          case ActPlayerFlag of
  9722.             FLAG_TERRA:  s2:='Übertritt zur Föderation wurde erklärt';
  9723.             FLAG_KLEGAN: s2:='Übertritt ins Reich wurde erklärt';
  9724.             FLAG_FERAGI: s2:='Übertritt zur Allianz wurde erklärt';
  9725.             otherwise s2:='übertritt ins Imperium wurde erklärt'
  9726.          end;
  9727.       end;
  9728.       PlanetLose:=true;
  9729.    end;
  9730.    SETNEWPLANETOWNER:=true;
  9731. end;
  9732.  
  9733.  
  9734. begin
  9735.    PlanetLose:=false;
  9736.    ModC:=0;
  9737.    MyPlanetHeader:=PPtr;
  9738.    with MyPlanetHeader^ do begin
  9739.       ActPProjects:=ProjectPtr;
  9740.       TheProject:=0; s1:=''; s2:='';
  9741.       if (Year mod 10=0) and (odd(Year div 10)=odd(PlanetNum)) then begin
  9742.          s1:='Energienotstand durch Energiemangel';
  9743.          if ActPProjects^[41]=0 then begin
  9744.             if ActPProjects^[30]=0 then begin
  9745.                if (Population>5500) and (Save.TechCosts[ActPlayer,ProjectNeedsTech[30]]<=0)
  9746.                and (ProjectID<>30) then begin                      { RECYCLINGANLAGE }
  9747.                   TheProject:=30;
  9748.                   s1:='Massensterben durch verseuchte Landstriche';
  9749.                end else exit;
  9750.             end else if ActPProjects^[32]=0 then begin
  9751.                if (Population>7000) and (Save.TechCosts[ActPlayer,ProjectNeedsTech[32]]<=0)
  9752.                and (ProjectID<>32) then TheProject:=32 else exit   { HYDROKRAFTWERK }
  9753.             end else if ActPProjects^[31]=0 then begin
  9754.                if (Population>9000) and (Save.TechCosts[ActPlayer,ProjectNeedsTech[31]]<=0)
  9755.                and (ProjectID<>31) then TheProject:=31 else exit   { FUSIONSKRAFTWERK }
  9756.             end else if ActPProjects^[42]=0 then begin
  9757.                if (Population>11500) and (Save.TechCosts[ActPlayer,ProjectNeedsTech[42]]<=0)
  9758.                and (ProjectID<>42) then begin
  9759.                   TheProject:=42;
  9760.                   s1:='Schwere Unwetter verwüsten Städte';
  9761.                end else exit;
  9762.             end else exit;
  9763.          end else exit;
  9764.          INFORMUSER;
  9765.          ModC:=GETTHESOUND(4);
  9766.          ModL:=ModMemL[4];
  9767.       end else begin
  9768.          if (random(80)<>0) and (Warnung[ActPlayer]=0) then exit;
  9769.          Population:=round(Population*0.895);
  9770.          if Warnung[ActPlayer]<>0 then begin
  9771.             i:=random(20);
  9772.             if (i in [2,3]) then i:=0;
  9773.          end else i:=random(10);
  9774.          case i of
  9775.             0: if ActPProjects^[28]=0 then begin    {kontinentale Union}
  9776.                   TheProject:=28;  s1:='Bürgerkrieg ausgebrochen';
  9777.                end else exit;
  9778.             1: if ActPProjects^[29]=0 then begin    {globale Union}
  9779.                   TheProject:=29;  s1:='Kriege zwischen den Nationen';
  9780.                end else exit;
  9781.             2: if Save.ProjectCosts[ActPlayer,4]<>0 then s1:='Massenepidemie durch unbekannten Virus' else exit;
  9782.             3: s1:='Klimakatastrophe durch Kometeneinschläge';
  9783.             otherwise if (PFlags and FLAG_CIV_MASK<>Ethno) and (FirstShip.NextShip=NIL)
  9784.             and (GetPlanetSys[GETCIVVAR(Ethno)]=0) then begin
  9785.                if (Warnung[ActPlayer]<>0) and (random(10)<>0) then exit;
  9786.                GetPlanet[GETCIVVAR(Ethno)]:=MyPlanetHeader;
  9787.                GetPlanetSys[GETCIVVAR(Ethno)]:=ActSys;
  9788.                OldPlanet:=MyPlanetHeader^;
  9789.                if (Save.CivPlayer[ActPlayer]<>0) then TheProject:=-1;
  9790.                s1:='Schwere ethnische Konflikte ausgebrochen';
  9791.                if PFlags and FLAG_CIV_MASK=ActPlayerFlag then s2:='Unabhängigkeit wurde erklärt';
  9792.                for i:=1 to pred(MAXCIVS) do
  9793.                 if Save.WarState[i,GETCIVVAR(Ethno)]=LEVEL_DIED then Save.WarState[i,GETCIVVAR(Ethno)]:=LEVEL_PEACE;
  9794.                if Save.WarState[GETCIVVAR(PFlags),GETCIVVAR(Ethno)]=LEVEL_DIED then Save.WarState[GETCIVVAR(PFlags),GETCIVVAR(Ethno)]:=LEVEL_COLDWAR;
  9795.                PFlags:=Ethno;
  9796.                if PFlags and FLAG_CIV_MASK=ActPlayerFlag then begin
  9797.                   case ActPlayerFlag of
  9798.                      FLAG_TERRA:  s2:='Übertritt zur Föderation wurde erklärt';
  9799.                      FLAG_KLEGAN: s2:='Übertritt ins Reich wurde erklärt';
  9800.                      FLAG_FERAGI: s2:='Übertritt zur Allianz wurde erklärt';
  9801.                      otherwise s2:='übertritt ins Imperium wurde erklärt'
  9802.                   end;
  9803.                end;
  9804.                PlanetLose:=true;
  9805.             end else if (Warnung[ActPlayer] in [1,2]) and (random(22)=0) then begin
  9806.                if not SETNEWPLANETOWNER then exit;
  9807.             end else if (Warnung[ActPlayer]=2) and (random(10)=0) then begin
  9808.                if not SETNEWPLANETOWNER then exit;
  9809.             end else exit;
  9810.          end;
  9811.       end;
  9812.  
  9813.       l:=GETCIVVAR(PFlags);
  9814.       if (Save.CivPlayer[GETCIVVAR(PFlags)]<>0) or (TheProject=-1) then begin
  9815.          INFORMUSER;
  9816.          if TheProject in [-1,28,29] then begin
  9817.             ModC:=GETTHESOUND(2);
  9818.             ModL:=ModMemL[2];
  9819.          end;
  9820.          MAKEBORDER(MyScreen[1]^,85,110,425,200,12,6,0);
  9821.          WRITE(256,161,12,1+16,MyScreen[1]^,3,s1);
  9822.          s:='System: '+Save.SystemName[ActSys]; WRITE(256,117,PFlags and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  9823.          s:='Planet: '+PName;                   WRITE(256,137,PFlags and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  9824.          if (TheProject>0) and (Save.TechCosts[ActPlayer,ProjectNeedsTech[TheProject]]<=0) then begin
  9825.             s:='Bürger fordern '+Project[TheProject];
  9826.             WRITE(256,178,12,1+16,MyScreen[1]^,3,s);
  9827.          end;
  9828.          if TheProject=-1 then WRITE(256,178,12,1+16,MyScreen[1]^,3,s2);
  9829.  
  9830.          if (Save.CivPlayer[GETCIVVAR(PFlags)]<>0) and (ActPlayer=GETCIVVAR(PFlags)) then begin
  9831.             MAKEBORDER(MyScreen[1]^,85,208,425,248,12,6,0);
  9832.             BltBitMapRastPort(^ImgBitMap7,Class*32,0,^MyScreen[1]^.RastPort,95,212,32,32,192);
  9833.             for k:=1 to 2 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,k*140,218);
  9834.             WRITE(198,220,0,16,MyScreen[1]^,4,'Planet');
  9835.             WRITE(338,220,0,16,MyScreen[1]^,4,'weiter');
  9836.             b:=false;
  9837.             if not Save.PlayMySelf then repeat
  9838.                delay(RDELAY);
  9839.                if (LData^ and 64=0) and (IBase^.MouseY in [218..238]) then begin
  9840.                   if IBase^.MouseX in [140..256] then begin
  9841.                      KLICKGAD(140,218);
  9842.                      b:=true;
  9843.                      HANDLEKNOWNPLANET(ActSys,0,MyPlanetHeader);
  9844.                   end else if IBase^.MouseX in [280..396] then begin
  9845.                      KLICKGAD(280,218);   b:=true;
  9846.                   end;
  9847.                end;
  9848.             until b;
  9849.             if Save.PlayMySelf then delay(PAUSE);
  9850.             RECT(MyScreen[1]^,0,85,208,425,248);
  9851.          end else begin
  9852.             if Save.PlayMySelf then delay(PAUSE);
  9853.             WAITLOOP(Save.PlayMySelf);
  9854.          end;
  9855.          RECT(MyScreen[1]^,0,85,110,425,200);
  9856.          if PlanetLose then CHECKPROJECTS(^OldPlanet,MyPlanetHeader^.PFlags);
  9857.       end;
  9858.       if ModC<>0 then begin
  9859.          StopPlayer;
  9860.          FreeMem(ModC,ModL);
  9861.       end;
  9862.    end;
  9863. end;
  9864.  
  9865.  
  9866.  
  9867. procedure DECREASE(ActSys :byte; PPtr :ptr;);
  9868.  
  9869. var ModC                :long;
  9870. var MyPlanetHeader      :^r_PlanetHeader;
  9871.  
  9872. begin
  9873.    MyPlanetHeader:=PPtr;
  9874.    with MyPlanetHeader^ do begin
  9875.       INFORMUSER;
  9876.       ModC:=GETTHESOUND(4);
  9877.       MAKEBORDER(MyScreen[1]^,80,120,430,220,12,6,0);
  9878.       s:='System: '+Save.SystemName[ActSys]; WRITE(256,127,PFlags and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  9879.       s:='Planet: '+PName;              WRITE(256,147,PFlags and FLAG_CIV_MASK,1+16,MyScreen[1]^,4,s);
  9880.       WRITE(256,170,12,16,MyScreen[1]^,4,'Dramatischer Bevölkerungsrückgang!');
  9881.       WRITE(256,190,12,16,MyScreen[1]^,4,'Biosphäre reinigen!');
  9882.       if Save.PlayMySelf then delay(PAUSE);
  9883.       WAITLOOP(Save.PlayMySelf);
  9884.       RECT(MyScreen[1]^,0,80,120,430,220);
  9885.       HANDLEKNOWNPLANET(ActSys,0,MyPlanetHeader);
  9886.       if ModC<>0 then begin
  9887.          StopPlayer;
  9888.          FreeMem(ModC,ModMemL[4]);
  9889.       end;
  9890.    end;
  9891. end;
  9892.  
  9893.  
  9894.  
  9895. procedure DOHUMANITY;
  9896.  
  9897. var Smallest,Biggest,i          :byte;
  9898. var SmallValue,BigValue         :long;
  9899. var Direction,Ende              :short;
  9900.  
  9901. begin
  9902.    Smallest:=1; Biggest:=1;
  9903.    SmallValue:=1000000000; BigValue:=0;
  9904.    if odd(Year) then begin
  9905.       i:=0; Ende:=(MAXCIVS-2); Direction:=1;
  9906.    end else begin
  9907.       i:=MAXCIVS; Ende:=1; Direction:=-1;
  9908.    end;
  9909.    repeat
  9910.       i:=i+Direction;
  9911.       if (Save.WarPower[i]>BigValue) and (Save.Bevölkerung[i]>0) then begin
  9912.          BigValue:=Save.WarPower[i];
  9913.          Biggest:=i;
  9914.       end;
  9915.       if (Save.WarPower[i]<SmallValue) and (Save.Bevölkerung[i]>1000) and
  9916.       ((Save.CivPlayer[i]=0) or Save.PlayMySelf) then begin
  9917.          SmallValue:=Save.WarPower[i];
  9918.          Smallest:=i;
  9919.       end;
  9920.    until i=Ende;
  9921.    if (Save.Bevölkerung[Smallest]>1000) and ((Save.CivPlayer[Smallest]=0) or Save.PlayMySelf)
  9922.     then begin
  9923.       Save.ImperatorState[Biggest]:=Save.ImperatorState[Biggest]+2;
  9924.       Save.Staatstopf[Biggest]:=Save.Staatstopf[Biggest]-(Save.WarPower[Biggest]*90);
  9925.       Save.Staatstopf[Smallest]:=Save.Staatstopf[Smallest]+(Save.WarPower[Biggest]*90);
  9926.    end;
  9927.    i:=GETCIVVAR(Save.WorldFlag);
  9928.    if i in [1..7] then if Save.Bevölkerung[Biggest]>Save.Bevölkerung[i]*3 then STOPCIVILWAR(0);
  9929.    if (Save.Bevölkerung[Biggest]>75000) and (random(255)=0) and (Save.WorldFlag=0)
  9930.     then CREATECIVILWAR(Biggest);
  9931. end;
  9932.  
  9933.  
  9934.  
  9935.  
  9936. begin { ROTATEPLANETS }
  9937.    if (Year>2000) and (ActPlayer=1) then DOHUMANITY;
  9938.    RECT(MyScreen[1]^,0,520,291,632,308);
  9939.    Valid:=false;
  9940.    if ActPlayer=1 then Year:=Year+1;
  9941.    FreeSystem:=false;
  9942.    if (Year mod 10=0) and not Save.PlayMySelf then INFORMUSER;
  9943.    AllCreative[ActPlayer]:=0;
  9944.    for j:=1 to 7 do if Save.ProjectCosts[ActPlayer,j]<=0 then
  9945.     if Year>0 then Save.ProjectCosts[ActPlayer,j]:=50*Year*j else Save.ProjectCosts[ActPlayer,j]:=180000*j;
  9946.    vNS:=true;
  9947.    if ActPlayer=1 then begin
  9948.       MaquesShips:=0;
  9949.       for i:=1 to MAXCIVS do begin
  9950.          Save.WarPower[i]:=0;
  9951.          Save.Bevölkerung[i]:=0;
  9952.          Militärausgaben[i]:=0;
  9953.       end;
  9954.    end;
  9955.    for i:=1 to Save.SYSTEMS do if (Save.ProjectCosts[ActPlayer,39]<=0) and vNS
  9956.    and (SystemHeader[i].vNS<>FLAG_KNOWN) and (random(5)=0) then begin
  9957.       SystemHeader[i].vNS:=FLAG_KNOWN;
  9958.       vNS:=false;
  9959.    end;
  9960.    for i:=1 to Save.SYSTEMS do if SystemHeader[i].Planets>0 then begin
  9961.       if ActPlayer=1 then for j:=1 to MAXCIVS do SystemFlags[j,i]:=SystemFlags[j,i] and FLAG_CIV_MASK;
  9962.       if (ActPlayer=1) and (SystemHeader[i].FirstShip.SType=TARGET_STARGATE) then with SystemHeader[i] do begin
  9963.          FromX:=FirstShip.PosX;
  9964.          FromY:=FirstShip.PosY;
  9965.          j:=round((SQRT(FirstShip.PosX*FirstShip.PosX+FirstShip.PosY*FirstShip.PosY)-1)/3);
  9966.          d:=1/((j*3)+1);
  9967.          sin_rot:=sin(d);  cos_rot:=cos(d);
  9968.          FirstShip.PosX:=round(FirstShip.PosX * cos_rot - FirstShip.PosY*sin_rot);
  9969.          FirstShip.PosY:=round(FirstShip.PosX * sin_rot + FirstShip.PosY*cos_rot*(1+d*d));
  9970.          MyShipPtr:=^SystemHeader[i].FirstShip;
  9971.          if FINDOBJECT(i,256+(FirstShip.PosX+OffsetX)*32,256+(FirstShip.PosY+OffsetY)*32,MyShipPtr) then begin
  9972.             FirstShip.PosX:=FromX;
  9973.             FirstShip.PosY:=FromY;
  9974.          end;
  9975.          if FirstShip.PosY=0 then begin
  9976.             if FirstShip.PosX>0 then FirstShip.PosX:=FirstShip.PosX-1;
  9977.             if FirstShip.PosX<0 then FirstShip.PosX:=FirstShip.PosX+1;
  9978.          end;
  9979.          if (FirstShip.PosX in [-3..2]) and (FirstShip.PosY in [-3..2]) then begin
  9980.             MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  9981.             s:='System: '+Save.SystemName[i];
  9982.             WRITE(256,131,12,16,MyScreen[1]^,4,s);
  9983.             WRITE(256,151,12,16,MyScreen[1]^,4,'Umlaufbahn kollabiert,');
  9984.             WRITE(256,171,12,16,MyScreen[1]^,4,'Stargate zerstört');
  9985.             if Save.PlayMySelf then delay(PAUSE);
  9986.             WAITLOOP(Save.PlayMySelf);
  9987.             RECT(MyScreen[1]^,0,85,120,425,200);
  9988.             FirstShip.SType:=0;
  9989.          end;
  9990.       end;
  9991.       if ActPlayer=1 then REFRESHSHIPS(SystemHeader[i].FirstShip.NextShip,i,1);
  9992.       if ActPlayer<MAXCIVS then for j:=1 to SystemHeader[i].Planets do begin
  9993.          PlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  9994.          if PlanetHeader<>NIL then with PlanetHeader^ do begin
  9995.             if (Ethno=FLAG_OTHER) and (Save.WorldFlag<>WFLAG_JAHADR) then Ethno:=PFlags and FLAG_CIV_MASK;
  9996.             if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) then begin
  9997.                if (ProjectPtr<>NIL) and (PFlags and FLAG_CIV_MASK<>0) then begin
  9998.                   ActPProjects:=ProjectPtr;
  9999.                   for k:=1 to 7 do if ActPProjects^[k]>0 then Save.ProjectCosts[GETCIVVAR(PFlags),k]:=0;
  10000.                end;
  10001.                CREATEPANIC(PlanetHeader,i,j);
  10002.             end;
  10003.             if ActPlayer=1 then begin
  10004.                { Bevölkerungswachstum }
  10005.                CivVar:=GETCIVVAR(PFlags);
  10006.                if (CivVar=0) and (Infrastruktur>0) then Infrastruktur:=abs(Infrastruktur-random(7));
  10007.                if (CivVar=0) and (Industrie>0) then Industrie:=abs(Industrie-random(7));
  10008.                if (CivVar in [1..MAXCIVS]) and (ProjectPtr<>NIL) then begin
  10009.                   ActPProjects:=ProjectPtr;
  10010.                   if ((Class=CLASS_EARTH)     and (Population div 1176<=Size))
  10011.                   or ((Class=CLASS_HALFEARTH) and (Population div  991<=Size))
  10012.                   or ((Class=CLASS_ICE)       and (Population div  743<=Size))
  10013.                   or ((Class=CLASS_WATER)     and (Population div  745<=Size))
  10014.                   or ((Class=CLASS_STONES)    and (Population div  929<=Size))
  10015.                   or ((Class=CLASS_DESERT)    and (Population div  739<=Size)) then begin
  10016.                      Population:=Population+1+(ActPProjects^[41]+ActPProjects^[42])*20;
  10017.                      Population:=round(Population*1.008);
  10018.                      if Save.ProjectCosts[CivVar,3]=0 then Population:=round(Population*1.028);
  10019.                      if Save.ProjectCosts[CivVar,4]=0 then Population:=round(Population*1.029);
  10020.                      if Population<1000 then Population:=round(Population*1.05);
  10021.                      if Population<2000 then Population:=round(Population*1.009);
  10022.                      if Population<3000 then Population:=round(Population*1.005);
  10023.                      if Population<0 then Population:=0;
  10024.                   end;
  10025.                   Save.Bevölkerung[CivVar]:=Save.Bevölkerung[CivVar]+Population;
  10026.                end else if ProjectPtr=NIL then ProjectPtr:=ptr(AllocMem(sizeof(ByteArr42),MEMF_CLEAR));
  10027.                if (Class=CLASS_PHANTOM) and (PlanetHeader^.FirstShip.NextShip<>NIL) then PlanetHeader^.FirstShip.NextShip^.Owner:=0;
  10028.                REFRESHSHIPS(FirstShip.NextShip,i,0);
  10029.                d:=1/((j*3)+1);
  10030.                sin_rot:=sin(d);  cos_rot:=cos(d);
  10031.                PosX:=PosX * cos_rot - PosY*sin_rot;
  10032.                PosY:=PosX * sin_rot + PosY*cos_rot*(1+d*d);
  10033.                if round(PosX)=round(PosY) then PosX:=round(PosY);
  10034.                if Population=0 then begin
  10035.                   PFlags:=0;   Ethno:=0;
  10036.                end;
  10037.             end;
  10038.          end;
  10039.       end;
  10040.    end;
  10041.    if ActSys>0 then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  10042.    if ActPlayer<MAXCIVS then for i:=1 to Save.SYSTEMS do if SystemHeader[i].Planets>0 then begin
  10043.       for j:=1 to MAXCIVS do SystemOwn[j]:=0;
  10044.       for j:=1 to SystemHeader[i].Planets do begin
  10045.          PlanetHeader:=ptr(SystemHeader[i].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  10046.          with PlanetHeader^ do begin
  10047.             CivVar:=GETCIVVAR(PlanetHeader^.PFlags);
  10048.             if CivVar in [1..MAXCIVS] then SystemOwn[CivVar]:=SystemOwn[CivVar]+Population;
  10049.             if (PlanetHeader^.PFlags and FLAG_CIV_MASK in [0,ActPlayerFlag])
  10050.             and (PlanetHeader^.Class in [CLASS_WATER,CLASS_ICE,CLASS_EARTH,
  10051.             CLASS_HALFEARTH,CLASS_DESERT]) then begin
  10052.                b:=false;
  10053.                if (Water div Size>80) and not (Class in [CLASS_WATER,CLASS_ICE]) then begin
  10054.                   Class:=CLASS_WATER; b:=true;
  10055.                end else if (Water div Size in [55..80]) and (Class<>CLASS_EARTH) then begin
  10056.                   Class:=CLASS_EARTH; b:=true;
  10057.                end else if (Water div Size in [21..54]) and not (Class in [CLASS_HALFEARTH,CLASS_STONES]) then begin
  10058.                   Class:=CLASS_HALFEARTH; b:=true;
  10059.                end else if (Water div Size<21) and (Class<>CLASS_DESERT) then begin
  10060.                   Class:=CLASS_DESERT; b:=true;
  10061.                end;
  10062.                if b and (PlanetHeader^.PFlags and FLAG_CIV_MASK=ActPlayerFlag)
  10063.                and (Save.CivPlayer[ActPlayer]<>0) and (Year>1900) then begin
  10064.                   INFORMUSER;
  10065.                   MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  10066.                   s:='System: '+Save.SystemName[i]; WRITE(256,127,ActPlayerFlag,1+16,MyScreen[1]^,4,s);
  10067.                   s:='Planet: '+PName;         WRITE(256,147,ActPlayerFlag,1+16,MyScreen[1]^,4,s);
  10068.                   s:='wird zu Planet der Klasse ';
  10069.                   case Class of
  10070.                      CLASS_DESERT    : s:=s+'D';
  10071.                      CLASS_HALFEARTH : s:=s+'H';
  10072.                      CLASS_EARTH     : s:=s+'M';
  10073.                      CLASS_WATER     : s:=s+'W';
  10074.                      otherwise;
  10075.                   end;
  10076.                   WRITE(256,173,12,1+16,MyScreen[1]^,4,s);
  10077.                   if Save.PlayMySelf then delay(PAUSE);
  10078.                   WAITLOOP(Save.PlayMySelf);
  10079.                   RECT(MyScreen[1]^,0,85,120,425,200);
  10080.                   REFRESHDISPLAY;
  10081.                end;
  10082.             end;
  10083.             if PFlags and FLAG_CIV_MASK=ActPlayerFlag then begin
  10084.                if (ProjectID in [1..7,39]) and (Save.ProjectCosts[ActPlayer,ProjectID]<=0) then begin
  10085.                   if (ProjectID=39) and (Save.ProjectCosts[ActPlayer,39]>0) then
  10086.                    for k:=1 to MAXCIVS do if k<>ActPlayer then vNSonde[k]:=true;
  10087.                   if (Save.CivPlayer[GETCIVVAR(PFlags)]<>0) and not Save.PlayMySelf
  10088.                   then begin
  10089.                      INFORMUSER;
  10090.                      HANDLEKNOWNPLANET(i,1,PlanetHeader)
  10091.                   end else ProjectID:=0;
  10092.                end;
  10093.                ActPProjects:=ProjectPtr;
  10094.                if ActPProjects^[34] in [1..99] then ActPProjects^[34]:=round(ActPPRojects^[34]*1.2)+1;
  10095.                if ActPProjects^[40] in [1..99] then ActPProjects^[40]:=round(ActPPRojects^[40]*1.2)+1;
  10096.  
  10097.                SystemFlags[ActPlayer,i]:=SystemFlags[ActPlayer,i] or FLAG_KNOWN;
  10098.  
  10099.                PProd:=11+(ActPProjects^[31]+ActPProjects^[37]
  10100.                         +ActPProjects^[38]+ActPProjects^[41]
  10101.                         +ActPProjects^[42])*6;
  10102.  
  10103.                PCreativity:=20+(ActPProjects^[33]+ActPProjects^[35]+ActPProjects^[36]+
  10104.                                 ActPProjects^[38]+ActPProjects^[42])*10;
  10105.                AllCreative[ActPlayer]:=AllCreative[ActPlayer]+round(PCreativity*(Biosphäre/80+Population/400))+1;
  10106.                if ActPProjects^[41]=0 then begin       { Keine MICROIDEN, Biosphären-Abbau }
  10107.                   l:=4+(ActPProjects^[30]+               { Recycling-Anl. }
  10108.                         ActPProjects^[31]+               { Fusions-Kraftwerk }
  10109.                         ActPProjects^[32]+               { Hydro-Kraftwerk }
  10110.                         ActPProjects^[37]+               { intell. Fabrik }
  10111.                         ActPProjects^[42])*2;            { Wetter-Sat }
  10112.                   if (Biosphäre>0) and (random(l)=0) then Biosphäre:=Biosphäre-2;
  10113.                   if (Biosphäre in [0..127]) and (Population>30) then begin          { Biosphäre<73%,
  10114.                                                          Infra-,Industrie- und
  10115.                                                          Bevölkerungsabbau}
  10116.                      if random(8)=0 then begin
  10117.                         if Infrastruktur>1 then Infrastruktur:=Infrastruktur-2;
  10118.                         if Industrie>1 then Industrie:=Industrie-2;
  10119.                      end;
  10120.                      Population:=round(Population*0.95);
  10121.                      if (ProjectID<>-3) and (Save.CivPlayer[GETCIVVAR(PFlags)]<>0)
  10122.                      and not Save.PlayMySelf then DECREASE(i,PlanetHeader);
  10123.                   end;
  10124.                   if (random(20)=0) and (Infrastruktur>1) then Infrastruktur:=Infrastruktur-1;
  10125.                   if (random(20)=0) and (Industrie>1) then Industrie:=Industrie-1;
  10126.                end else begin
  10127.                   Biosphäre:=Biosphäre+2;         if Biosphäre>200 then Biosphäre:=200;
  10128.                   Infrastruktur:=Infrastruktur+3; if Infrastruktur>200 then Infrastruktur:=200;
  10129.                   Industrie:=Industrie+2;         if Industrie>200 then Industrie:=200;
  10130.                end;
  10131.                l:=0;
  10132.                if ((Save.CivPlayer[ActPlayer]=0) or Save.PlayMySelf) and (ProjectID=0) then ProjectID:=-1;
  10133.                if ProjectID<>0 then begin
  10134.                   l:=0;
  10135.                   if ProjectID<0 then begin
  10136.                      case ProjectID of
  10137.                         -3: begin
  10138.                                Biosphäre:=Biosphäre+9;
  10139.                                if Biosphäre>200 then begin
  10140.                                   l:=1; Biosphäre:=200;
  10141.                                end;
  10142.                             end;
  10143.                         -2: begin
  10144.                                Infrastruktur:=Infrastruktur+9;
  10145.                                if Infrastruktur>200 then begin
  10146.                                   l:=1; Infrastruktur:=200;
  10147.                                end;
  10148.                             end;
  10149.                         otherwise begin
  10150.                                Industrie:=Industrie+9;
  10151.                                if Industrie>200 then begin
  10152.                                   l:=1; Industrie:=200;
  10153.                                end;
  10154.                         end;
  10155.                      end;
  10156.                   end else begin
  10157.                      PMoney:=round(PProd*(Infrastruktur/17+Industrie/17+Population/17))+1;
  10158.                      while PMoney>MAXPMONEY do PMoney:=round(PMoney*0.95);
  10159.                      if Save.CivPlayer[ActPlayer]<>0
  10160.                       then PMoney:=round(PMoney*(100-Save.JSteuer[ActPlayer]-Save.GSteuer[ActPlayer]-Save.SService[ActPlayer])/100)
  10161.                      else PMoney:=round(PMoney*(100-Save.JSteuer[ActPlayer]-Save.GSteuer[ActPlayer])/100);
  10162.                      XProjectPayed:=XProjectPayed+PMoney;
  10163.  
  10164.                      {*** Überschüssige Finanzen für Planeten ausgeben ***}
  10165.                      if (Save.Staatstopf[ActPlayer]>XProjectCosts*10) and
  10166.                      (Save.GSteuer[ActPlayer]<=2) and
  10167.                      ((Save.CivPlayer[ActPlayer]=0) or Save.PlayMySelf)
  10168.                      then begin
  10169.                         Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-(XProjectCosts-XProjectPayed);
  10170.                         XProjectPayed:=XProjectCosts;
  10171.                      end;
  10172.                      if random(100)<50 then if ((Save.CivPlayer[ActPlayer]=0) or (Save.PlayMySelf))
  10173.                      and (XProjectCosts>XProjectPayed) and (Save.GSteuer[ActPlayer]<15)
  10174.                      and (Save.Staatstopf[ActPlayer]>3000) then begin
  10175.                         if ((Save.Staatstopf[ActPlayer]*0.7)>Militärausgaben[ActPlayer]*15) then begin
  10176.                            XProjectPayed:=round(XProjectPayed+(Save.Staatstopf[ActPlayer]*0.3));
  10177.                            Save.Staatstopf[ActPlayer]:=round(Save.Staatstopf[ActPlayer]*0.7);
  10178.                         end else if ((Save.Staatstopf[ActPlayer]*0.85)>Militärausgaben[ActPlayer]*9) then begin
  10179.                            XProjectPayed:=round(XProjectPayed+(Save.Staatstopf[ActPlayer]*0.15));
  10180.                            Save.Staatstopf[ActPlayer]:=round(Save.Staatstopf[ActPlayer]*0.85);
  10181.                         end else if ((Save.Staatstopf[ActPlayer]*0.9)>Militärausgaben[ActPlayer]*8) then begin
  10182.                            XProjectPayed:=round(XProjectPayed+(Save.Staatstopf[ActPlayer]*0.1));
  10183.                            Save.Staatstopf[ActPlayer]:=round(Save.Staatstopf[ActPlayer]*0.9);
  10184.                         end else if (Save.Staatstopf[ActPlayer]>Militärausgaben[ActPlayer]*7)
  10185.                         and (Year>0) then begin
  10186.                            XProjectPayed:=XProjectPayed+Year*2;
  10187.                            Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-Year*2;
  10188.                         end;
  10189.                      end;
  10190.  
  10191.                      if (PFlags and FLAG_CIV_MASK=FLAG_OTHER) and (ProjectID=7) then ProjectID:=0;
  10192.                   end;
  10193.                   if (ProjectID>0) and (abs(XProjectPayed)>XProjectCosts) then begin
  10194.                      XProjectPayed:=XProjectPayed-XProjectCosts;
  10195.                      ActPProjects:=ProjectPtr;
  10196.                      if ProjectID in [34,40] then ActPPRojects^[ProjectID]:=100
  10197.                      else if ProjectID in [1..7,25..38,40..42] then ActPProjects^[ProjectID]:=ActPProjects^[ProjectID]+1
  10198.                      else if ProjectID in [8..24] then begin
  10199.                         if MaquesShips<MAXMAQUES then if CREATEMAQUESSHIP(i,ProjectID) then begin end;
  10200.                         l:=AllocMem(sizeof(r_ShipHeader),MEMF_CLEAR);
  10201.                         ActShipPtr:=ptr(l);
  10202.                         ActShipPtr^:=r_ShipHeader(0,ProjectID,PFlags and FLAG_CIV_MASK,0,0,0,0,0,0,
  10203.                                                   ShipData[ProjectID].MaxShield,1,1,
  10204.                                                   ShipData[ProjectID].MaxMove,0,0,0,NIL,NIL,NIL);
  10205.                                                  {Age,SType,Owner,Flags,ShieldBonus,Ladung,Fracht,PosX,PosY,
  10206.                                                   Shield,Weapon,Repair
  10207.                                                   Moving,Source,Target,Tactical,TargetShip,BeforeShip,NextShip}
  10208.                         with ActShipPtr^ do begin
  10209.                            Weapon:=WEAPON_GUN;
  10210.                            if Save.TechCosts[ActPlayer,15]<=0 then Weapon:=WEAPON_LASER;
  10211.                            if Save.TechCosts[ActPlayer,24]<=0 then Weapon:=WEAPON_PHASER;
  10212.                            if Save.TechCosts[ActPlayer,32]<=0 then Weapon:=WEAPON_DISRUPTOR;
  10213.                            if Save.TechCosts[ActPlayer,27]<=0 then Weapon:=WEAPON_PTORPEDO;
  10214.                         end;
  10215.                         if (ProjectID=21) and (SystemHeader[i].FirstShip.SType=0)
  10216.                         and ((Save.CivPlayer[GETCIVVAR(ActShipPtr^.Owner)]=0) or Save.PlayMySelf) then begin
  10217.                            ActShipPtr^.PosX:=round(PosX);
  10218.                            ActShipPtr^.PosY:=round(PosY);
  10219.                            LINKSHIP(ActShipPtr,^SystemHeader[i].FirstShip,0);
  10220.                         end else LINKSHIP(ActShipPtr,^PlanetHeader^.FirstShip,0);
  10221.                      end;
  10222.                      if ProjectID in [1..7,39] then Save.ProjectCosts[ActPlayer,ProjectID]:=0;
  10223.                      l:=1;
  10224.                   end;
  10225.                   if l=1 then begin
  10226.                      if ProjectID in [1..7] then begin
  10227.                         Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+150;
  10228.                         if Save.stProject[ProjectID]=0 then begin
  10229.                            INFORMUSER;
  10230.                            Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+50;
  10231.                            Save.stProject[ProjectID]:=ActPlayer;
  10232.                            MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  10233.                            s:=GETCIVNAME(ActPlayer)+' führen als erste';
  10234.                            WRITE(256,127,GETCIVFLAG(ActPlayer),1+16,MyScreen[1]^,4,s);
  10235.                            s:=Project[ProjectID]+'-';
  10236.                            WRITE(256,149,12,1+16,MyScreen[1]^,4,s);
  10237.                            s:='durch!';
  10238.                            if ProjectID in [1..3] then s:='Projekt '+s;
  10239.                            WRITE(256,173,12,1+16,MyScreen[1]^,4,s);
  10240.                            if Save.PlayMySelf then delay(PAUSE);
  10241.                            WAITLOOP(Save.PlayMySelf);
  10242.                            Rect(MyScreen[1]^,0,85,120,425,200);
  10243.                         end;
  10244.                      end else if ProjectID in [8..24] then begin
  10245.                         if Save.CivPlayer[ActPlayer]<>0 then begin
  10246.                            btx:=1; XState:=0; Fight:=0;
  10247.                            for k:=1 to 6 do begin
  10248.                               if (Save.Military[ActPlayer] and btx=btx) then begin
  10249.                                  XState:=XState+i;
  10250.                                  Fight:=Fight+8;
  10251.                               end;
  10252.                               btx:=btx*2;
  10253.                            end;
  10254.                            Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-XState;
  10255.                            ActShipPtr^.ShieldBonus:=Fight;
  10256.                         end else ActShipPtr^.ShieldBonus:=round(Level*2-2);
  10257.                      end else if ProjectID in [26,28..42] then Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+10;
  10258.                      if ProjectID in [26,27] then Population:=Population-10;
  10259.                   end;
  10260.                   if (l=1) and (Save.CivPlayer[ActPlayer]<>0) then begin
  10261.                      INFORMUSER;
  10262.                      MAKEBORDER(MyScreen[1]^,85,120,425,200,12,6,0);
  10263.                      s:='System: '+Save.SystemName[i]; WRITE(256,127,ActPlayerFlag,1+16,MyScreen[1]^,4,s);
  10264.                      s:='Planet: '+PName;              WRITE(256,147,ActPlayerFlag,1+16,MyScreen[1]^,4,s);
  10265.                      if ProjectID>0 then s:='baut '+Project[ProjectID]
  10266.                      else case ProjectID of
  10267.                         -3: s:='Biosphäre gereinigt';
  10268.                         -2: s:='Infrastruktur repariert';
  10269.                         otherwise s:='Industrieanlagen repariert';
  10270.                      end;
  10271.                      WRITE(256,173,12,1+16,MyScreen[1]^,4,s);
  10272.                      delay(5);
  10273.                      if (ProjectID in [8..24]) and not Save.PlayMySelf then begin
  10274.                         MAKEBORDER(MyScreen[1]^,85,208,425,248,12,6,0);
  10275.                         BltBitMapRastPort(^ImgBitMap4,(ProjectID-8)*32,32,^MyScreen[1]^.RastPort,95,212,32,32,192);
  10276.                         for k:=1 to 2 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,k*140,218);
  10277.                         WRITE(198,220,0,16,MyScreen[1]^,4,'Space');
  10278.                         WRITE(338,220,0,16,MyScreen[1]^,4,'Orbit');
  10279.                         b:=false;
  10280.                         repeat
  10281.                            delay(RDELAY);
  10282.                            if (LData^ and 64=0) then begin
  10283.                               if IBase^.MouseY in [218..238] then begin
  10284.                                  if IBase^.MouseX in [140..256] then begin
  10285.                                     KLICKGAD(140,218);
  10286.                                     b:=true;
  10287.                                     ActShipPtr^.PosX:=round(PlanetHeader^.PosX);
  10288.                                     ActShipPtr^.PosY:=round(PlanetHeader^.PosY);
  10289.                                     LINKSHIP(ActShipPtr,^SystemHeader[i].FirstShip,1);
  10290.                                  end else if IBase^.MouseX in [280..396] then begin
  10291.                                     KLICKGAD(280,218);   b:=true;
  10292.                                  end;
  10293.                               end;
  10294.                            end;
  10295.                         until b;
  10296.                         RECT(MyScreen[1]^,0,85,208,425,248);
  10297.                      end else begin
  10298.                         if Save.PlayMySelf then delay(PAUSE);
  10299.                         WAITLOOP(Save.PlayMySelf);
  10300.                      end;
  10301.                      RECT(MyScreen[1]^,0,85,120,425,200);
  10302.                      REFRESHDISPLAY;
  10303.                      if not (ProjectID in [8..24,26,27]) then ProjectID:=0;
  10304.                      if not Save.PlayMySelf then HANDLEKNOWNPLANET(i,1,PlanetHeader);
  10305.                   end;
  10306.                   if ((l=1) or (ProjectID in [-3..0])) and ((Save.CivPlayer[ActPlayer]=0) or Save.PlayMySelf) then begin
  10307.                      ProjectID:=0;
  10308.                      for k:=8 to 24 do
  10309.                      if (Save.TechCosts[ActPlayer,ProjectNeedsTech[k]]<=0)
  10310.                      and (ActPProjects^[ProjectNeedsProject[k]]>0) then begin
  10311.                         if ((k=21) and (ProjectID<18)) or
  10312.                         ((k>21) and (SystemHeader[i].FirstShip.SType and TARGET_STARGATE=TARGET_STARGATE))
  10313.                         or (k<=21) then ProjectID:=k;
  10314.                         if (ProjectID in [8,9]) and (Save.WarPower[ActPlayer]>40) then ProjectID:=0;
  10315.                      end;
  10316.                      if (ActPlayer=8) and (Save.WarPower[8]>5000) then ProjectID:=0;
  10317.                         {*** DCON`s begrenzen ***}
  10318.                      if PlanetHeader^.FirstShip.NextShip<>NIL then
  10319.                      if PlanetHeader^.FirstShip.NextShip^.NextShip<>NIL then begin
  10320.                         MyShipPtr:=PlanetHeader^.FirstShip.NextShip^.NextShip;
  10321.                         if (Save.WarState[ActPlayer,1] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10322.                            (Save.WarState[ActPlayer,2] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10323.                            (Save.WarState[ActPlayer,3] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10324.                            (Save.WarState[ActPlayer,4] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10325.                            (Save.WarState[ActPlayer,5] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10326.                            (Save.WarState[ActPlayer,6] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10327.                            (Save.WarState[ActPlayer,7] in [LEVEL_WAR,LEVEL_COLDWAR]) or
  10328.                            (Save.WarState[ActPlayer,8] in [LEVEL_WAR,LEVEL_COLDWAR]) then begin
  10329.                         { Krieg mit anderer Zivi }
  10330.                            if ActPProjects^[27]<1 then ProjectID:=27;
  10331.                            while (MyShipPtr<>NIL) and (MyShipPtr^.NextShip<>NIL) do begin
  10332.                               if (MyShipPtr^.Ladung and MASK_LTRUPPS=0) and (ActPPRojects^[27]>0) and
  10333.                               (ShipData[MyShipPtr^.SType].MaxLoad>(MyShipPtr^.Ladung and MASK_SIEDLER) div 16
  10334.                               + (MyShipPtr^.Ladung and MASK_LTRUPPS)) then begin
  10335.                                  ActPProjects^[27]:=ActPProjects^[27]-1;
  10336.                                  MyShipPtr^.Ladung:=MyShipPtr^.Ladung+1;
  10337.                               end;
  10338.                               ActShipPtr:=MyShipPtr^.NextShip;
  10339.                               MyShipPtr^.PosX:=round(PlanetHeader^.PosX);
  10340.                               MyShipPtr^.PosY:=round(PlanetHeader^.PosY);
  10341.                               LINKSHIP(MyShipPtr,^SystemHeader[i].FirstShip,1);
  10342.                               FINDENEMYOBJECT(i,MyShipPtr);
  10343.                               MyShipPtr:=ActShipPtr;
  10344.                            end;
  10345.                         end else if (SystemHeader[i].State and STATE_TACTICAL<>STATE_ALL_OCC)
  10346.                         and (Save.GlobalFlags[ActPlayer]=GFLAG_EXPLORE) then begin
  10347.                         {*** Noch nicht alle Planeten des Systems besiedelt! ***}
  10348.                            if ActPProjects^[26]>=ShipData[MyShipPtr^.SType].MaxLoad then begin
  10349.                               for k:=1 to ShipData[MyShipPtr^.SType].MaxLoad do
  10350.                               if (ActPProjects^[26]>0) and
  10351.                                (ShipData[MyShipPtr^.SType].MaxLoad>(MyShipPtr^.Ladung and MASK_SIEDLER) div 16
  10352.                                +(MyShipPtr^.Ladung and MASK_LTRUPPS)) then begin
  10353.                                  ActPProjects^[26]:=ActPProjects^[26]-1;
  10354.                                  MyShipPtr^.Ladung:=MyShipPtr^.Ladung+16;
  10355.                               end;
  10356.                               MyShipPtr^.PosX:=round(PlanetHeader^.PosX);
  10357.                               MyShipPtr^.PosY:=round(PlanetHeader^.PosY);
  10358.                               l:=GOTONEXTPLANET(i,MyShipPtr);
  10359.                            end else ProjectID:=26;
  10360.                         end else if (SystemHeader[i].State and STATE_TACTICAL=STATE_ALL_OCC)
  10361.                         and (Save.GlobalFlags[ActPlayer]=GFLAG_EXPLORE) then begin
  10362.                         {*** Expedition in andere Galaxie ***}
  10363.                            if random(100)<15 then l:=2 else begin
  10364.                               if ActPProjects^[26]+ActPProjects^[27]>ShipData[MyShipPtr^.SType].MaxLoad then begin
  10365.                                  MyShipPtr^.PosX:=round(PlanetHeader^.PosX);
  10366.                                  MyShipPtr^.PosY:=round(PlanetHeader^.PosY);
  10367.                                  for k:=1 to ShipData[MyShipPtr^.SType].MaxLoad do begin
  10368.                                     if (ActPProjects^[26]>1) and (ShipData[MyShipPtr^.SType].MaxLoad
  10369.                                     >((MyShipPtr^.Ladung and MASK_SIEDLER) div 16)+(MyShipPtr^.Ladung and MASK_LTRUPPS)) then begin
  10370.                                        ActPProjects^[26]:=ActPProjects^[26]-1;
  10371.                                        MyShipPtr^.Ladung:=MyShipPtr^.Ladung+16;
  10372.                                     end;
  10373.                                     if (ActPProjects^[27]>1) and (ShipData[MyShipPtr^.SType].MaxLoad
  10374.                                     >((MyShipPtr^.Ladung and MASK_SIEDLER) div 16)+(MyShipPtr^.Ladung and MASK_LTRUPPS)) then begin
  10375.                                        ActPProjects^[27]:=ActPProjects^[27]-1;
  10376.                                        MyShipPtr^.Ladung:=MyShipPtr^.Ladung+1;
  10377.                                     end;
  10378.                                  end;
  10379.                                  l:=GOTONEXTSYSTEM(i,MyShipPtr);
  10380.                               end else begin
  10381.                                  if ActPProjects^[26]<ShipData[MyShipPtr^.SType].MaxLoad then ProjectID:=26;
  10382.                                  if ActPProjects^[27]<2 then ProjectID:=27 else ProjectID:=26;
  10383.                               end;
  10384.                            end;
  10385.                         end else if Save.GlobalFlags[ActPlayer]=GFLAG_ATTACK then begin
  10386.                         { Alles Besetzt, Krieg beginnen }
  10387.                            l:=0;
  10388.                            for k:=1 to pred(MAXCIVS) do if (k<>ActPlayer) and (Save.WarState[ActPlayer,k]=LEVEL_NO_ALLIANZ) then l:=k;
  10389.                            if l=0 then for k:=1 to pred(MAXCIVS) do if (k<>ActPlayer) and not (Save.WarState[ActPlayer,k] in [LEVEL_UNKNOWN,LEVEL_DIED]) then l:=k;
  10390.                            if l<>0 then Save.WarState[ActPlayer,l]:=LEVEL_COLDWAR;
  10391.                            l:=0;
  10392.                         end;
  10393.                         if FirstShip.NextShip<>NIL then
  10394.                         if (FirstShip.NextShip^.NextShip<>NIL) and (SystemHeader[i].State and STATE_TACTICAL=STATE_ALL_OCC)
  10395.                         and (ActPProjects^[26]=0) then begin
  10396.                            if ((Water div Size<55) and EXISTSPLANET(ActPlayer,i,1))
  10397.                            or ((Water div Size>56) and EXISTSPLANET(ActPlayer,i,2)) then begin
  10398.                               MyShipPtr:=PlanetHeader^.FirstShip.NextShip^.NextShip;
  10399.                               MyShipPtr^.PosX:=round(PlanetHeader^.PosX);
  10400.                               MyShipPtr^.PosY:=round(PlanetHeader^.PosY);
  10401.                               LINKSHIP(MyShipPtr,^SystemHeader[i].FirstShip,1);
  10402.                            end else if FirstShip.NextShip^.SType-FirstShip.NextShip^.NextShip^.SType>3 then
  10403.                             FirstShip.NextShip^.NextShip^.Owner:=0;
  10404.                         end;
  10405.                      end;
  10406.                      if (random(100)<35) then l:=2 else l:=0;
  10407.                      if (Year>2000) and (ProjectID in [8..24]) and (Save.WarPower[ActPlayer]<Year div 30) and (random(100)<65) then l:=0;
  10408.                       if (l=2) or (ProjectID=0) then begin
  10409.                         for k:=22 downto 1 do
  10410.                         if (Save.TechCosts[ActPlayer,ProjectNeedsTech[PriorityList[k]]]<=0)
  10411.                             { Technologie vorhanden }
  10412.                         and ((ActPProjects^[ProjectNeedsProject[PriorityList[k]]]>0)
  10413.                         or (Save.ProjectCosts[ActPlayer,ProjectNeedsProject[PriorityList[k]]]=0)) then begin
  10414.                                { evtl. nötiges Projekt vorhanden }
  10415.                             if ((PriorityList[k] in [1..7]) and (Save.ProjectCosts[ActPlayer,ProjectNeedsProject[PriorityList[k]]]=0)
  10416.                             and (Save.ProjectCosts[ActPlayer,PriorityList[k]]>0)) then ProjectID:=PriorityList[k];
  10417.                                { Großprojekt noch nicht gebaut }
  10418.                             if (PriorityList[k] in [25,28..42]) and (ActPProjects^[PriorityList[k]]=0)
  10419.                             then ProjectID:=PriorityList[k];
  10420.                                { Projekt noch nicht gebaut }
  10421.                         end;
  10422.                      end;
  10423.                      if Save.ProjectCosts[ActPlayer,1]>0 then ProjectID:=1;
  10424.                      if ProjectID=0 then begin
  10425.                         if Industrie<200 then ProjectID:=-1;
  10426.                         if Infrastruktur<200 then ProjectID:=-2;
  10427.                         if Biosphäre<200 then ProjectID:=-3;
  10428.                      end;
  10429.                      if ProjectID>0 then XProjectCosts:=Save.ProjectCosts[ActPlayer,ProjectID];
  10430.                   end;
  10431.                   if (Save.CivPlayer[ActPlayer]=0) or Save.PlayMySelf then begin
  10432.                      if Industrie<170 then ProjectID:=-1;
  10433.                      if Infrastruktur<170 then ProjectID:=-2;
  10434.                      if Biosphäre<170 then ProjectID:=-3;
  10435.                   end;
  10436.                   PMoney:=round(PProd*(Infrastruktur/17+Industrie/17+Population/17))+1;
  10437.                   while PMoney>MAXPMONEY do PMoney:=round(PMoney*0.95);
  10438.                   Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]+round(PMoney*Save.GSteuer[ActPlayer]/100);
  10439.                   if Save.WorldFlag=WFLAG_JAHADR
  10440.                    then Save.Staatstopf[8]:=Save.Staatstopf[8]+round(PMoney*Save.JSteuer[ActPlayer]/100);
  10441.                   {Steuerentrichtung}
  10442.                end else begin
  10443.                   PMoney:=round(PProd*(Infrastruktur/17+Industrie/17+Population/17))+1;
  10444.                   while PMoney>MAXPMONEY do PMoney:=round(PMoney*0.95);
  10445.                   Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]+round(PMoney/3);
  10446.                   if Save.WorldFlag=WFLAG_JAHADR
  10447.                    then Save.Staatstopf[8]:=Save.Staatstopf[8]+round(PMoney*Save.JSteuer[ActPlayer]/100);
  10448.                   {Steuerentrichtung}
  10449.                   {keine Produktion}
  10450.                end;
  10451.                if Save.CivPlayer[ActPlayer]<>0 then begin
  10452.                   repeat
  10453.                      k:=random(pred(MAXCIVS))+1;
  10454.                   until k<>ActPlayer;
  10455.                   if not (Save.WarState[ActPlayer,k] in [LEVEL_DIED,LEVEL_UNKNOWN]) then
  10456.                    Save.SSMoney[ActPlayer,k]:=Save.SSMoney[ActPlayer,k]+round(PMoney/100*Save.SService[ActPlayer]);
  10457.                   if (Year mod 5=0) and (random(200)=0) then Save.SSMoney[ActPlayer,k]:=0;
  10458.                end;
  10459.             end;
  10460.          end;
  10461.       end;
  10462.       l:=0;
  10463.       if SystemOwn[1]>0 then l:=FLAG_TERRA;
  10464.       if SystemOwn[2]>SystemOwn[1] then begin
  10465.          l:=FLAG_KLEGAN;
  10466.          SystemOwn[1]:=SystemOwn[2];
  10467.       end;
  10468.       if SystemOwn[3]>SystemOwn[1] then begin
  10469.          l:=FLAG_REMALO;
  10470.          SystemOwn[1]:=SystemOwn[3];
  10471.       end;
  10472.       if SystemOwn[4]>SystemOwn[1] then begin
  10473.          l:=FLAG_CARDAC;
  10474.          SystemOwn[1]:=SystemOwn[4];
  10475.       end;
  10476.       if SystemOwn[5]>SystemOwn[1] then begin
  10477.          l:=FLAG_FERAGI;
  10478.          SystemOwn[1]:=SystemOwn[5];
  10479.       end;
  10480.       if SystemOwn[6]>SystemOwn[1] then begin
  10481.          l:=FLAG_BAROJA;
  10482.          SystemOwn[1]:=SystemOwn[6];
  10483.       end;
  10484.       if SystemOwn[7]>SystemOwn[1] then begin
  10485.          l:=FLAG_VOLKAN;
  10486.          SystemOwn[1]:=SystemOwn[7]
  10487.       end;
  10488.       if SystemOwn[8]>SystemOwn[1] then l:=FLAG_OTHER;
  10489.       SystemFlags[1,i]:=(SystemFlags[1,i] and FLAG_KNOWN) or l;
  10490.       if SystemFlags[1,i] and FLAG_CIV_MASK=0 then FreeSystem:=true;
  10491.       if FreeSystem then SystemHeader[i].State:=SystemHeader[i].State and not STATE_ALL_OCC;
  10492.    end;
  10493.    if FreeSystem and not ((Save.WarState[ActPlayer,1]=LEVEL_WAR) or
  10494.    (Save.WarState[ActPlayer,2]=LEVEL_WAR) or (Save.WarState[ActPlayer,3]=LEVEL_WAR) or
  10495.    (Save.WarState[ActPlayer,4]=LEVEL_WAR) or (Save.WarState[ActPlayer,5]=LEVEL_WAR) or
  10496.    (Save.WarState[ActPlayer,6]=LEVEL_WAR) or (Save.WarState[ActPlayer,7]=LEVEL_WAR) or
  10497.    (Save.WarState[ActPlayer,8]=LEVEL_WAR)) then Save.GlobalFlags[ActPlayer]:=GFLAG_EXPLORE;
  10498.    Valid:=true;
  10499.    REFRESHDISPLAY;
  10500.    if ActPlayer=1 then if Year mod 50=0 then for i:=1 to pred(MAXCIVS) do
  10501.     if (Save.WarState[ActPlayer,i] in [LEVEL_ALLIANZ,LEVEL_NO_ALLIANZ]) then begin
  10502.       Save.WarState[i,ActPlayer]:=LEVEL_PEACE;
  10503.       Save.WarState[ActPlayer,i]:=LEVEL_PEACE;
  10504.    end;
  10505.    PRINTGLOBALINFOS(ActPlayer);
  10506.    if ((Year mod (18+ActPlayer)=0)
  10507.    or (not (Save.WorldFlag in [0,WFLAG_CEBORC,WFLAG_FIELD]) and (ActPlayer=8) and (Year mod 8=0)))
  10508.    and (Save.CivPlayer[ActPlayer]=0) then begin
  10509.       repeat
  10510.          i:=random(7)+1;
  10511.       until i<>ActPlayer;
  10512.       if not (Save.WarState[ActPlayer,i] in [LEVEL_DIED,LEVEL_UNKNOWN,LEVEL_ALLIANZ,LEVEL_WAR])
  10513.       and (Save.WarPower[i]<Save.WarPower[ActPlayer]) then Save.WarState[ActPlayer,i]:=LEVEL_COLDWAR;
  10514.    end;
  10515.    if (Year mod 18=0) and (Save.WarPower[2]>42) and (ActPlayer=2)
  10516.    and (Save.CivPlayer[ActPlayer]=0) then begin
  10517.       repeat
  10518.          i:=random(7)+1;
  10519.       until i<>2;
  10520.       if not (Save.WarState[2,i] in [LEVEL_DIED,LEVEL_UNKNOWN,LEVEL_ALLIANZ,LEVEL_WAR])
  10521.       then Save.WarState[2,i]:=LEVEL_COLDWAR;
  10522.    end;
  10523.    if (Year mod 17=0) and (Save.WarPower[4]>47) and (ActPlayer=4)
  10524.    and (Save.CivPlayer[ActPlayer]=0)  then begin
  10525.       repeat
  10526.          i:=random(7)+1;
  10527.       until i<>4;
  10528.       if not (Save.WarState[4,i] in [LEVEL_DIED,LEVEL_UNKNOWN,LEVEL_WAR])
  10529.       then Save.WarState[4,i]:=LEVEL_COLDWAR;
  10530.    end;
  10531.  
  10532.    if ActPlayer<MAXCIVS then if (Year>1901) or (Year<0) then begin
  10533.       if Save.ActTech[ActPlayer]<>0 then begin { Forschung }
  10534.          if AllCreative[ActPlayer]<0 then Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]:=0 else
  10535.          Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]:=Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]-AllCreative[ActPlayer];
  10536.          if Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]<=0 then begin
  10537.             Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]+50;
  10538.             if (Save.CivPlayer[ActPlayer]<>0) then begin
  10539.                INFORMUSER;
  10540.                DISPLAYTECH(Save.ActTech[ActPlayer],ActPlayer);
  10541.             end;
  10542.             Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]:=0;
  10543.          end;
  10544.       end;
  10545.       if (Save.CivPlayer[ActPlayer]=0) or Save.PlayMySelf then begin
  10546.          if Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]<=0 then begin
  10547.             Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]:=0;
  10548.             l:=Save.ActTech[ActPlayer];
  10549.             Save.ActTech[ActPlayer]:=0;
  10550.             repeat
  10551.                if l=0 then j:=3
  10552.                else if l=3 then j:=5
  10553.                else if l=5 then j:=11
  10554.                else if l=11 then j:=4
  10555.                else if l=4 then j:=16
  10556.                else j:=succ(random(42));
  10557.                if Save.TechCosts[ActPlayer,j]>0 then begin
  10558.                   if TechUse1[j]=0 then Save.ActTech[ActPlayer]:=j
  10559.                   else if ((Save.TechCosts[ActPlayer,TechUse1[j]]<=0) and (Save.TechCosts[ActPlayer,TechUse2[j]]<=0)) then
  10560.                   Save.ActTech[ActPlayer]:=j;
  10561.                end;
  10562.                l:=-1;
  10563.             until (Save.ActTech[ActPlayer]<>0) or (Save.TechCosts[ActPlayer,42]<=0);
  10564.          end;
  10565.          if (ActPlayer=8) and (Save.ActTech[ActPlayer]=42) then Save.ActTech[ActPlayer]:=0;
  10566.          if (Save.ActTech[ActPlayer]=42) and (Save.ProjectCosts[ActPlayer,6]>0) then Save.ActTech[ActPlayer]:=0;
  10567.       end else if (Save.ActTech[ActPlayer]=0) or (Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]]<=0) then begin
  10568.          Save.ActTech[ActPlayer]:=0;
  10569.          for j:=1 to 6 do NewTech[j]:=0;
  10570.          j:=1; i:=1;
  10571.          repeat
  10572.             if Save.TechCosts[ActPlayer,i]>0 then begin
  10573.                if TechUse1[i]=0 then begin
  10574.                   NewTech[j]:=i; j:=j+1;
  10575.                end else if ((Save.TechCosts[ActPlayer,TechUse1[i]]<=0) and (Save.TechCosts[ActPlayer,TechUse2[i]]<=0)) then begin
  10576.                  NewTech[j]:=i; j:=j+1;
  10577.                end;
  10578.             end;
  10579.             i:=i+1;
  10580.          until (i>42) or (j>6);
  10581.          if NewTech[1]<>0 then begin
  10582.             if (NewTech[1]=42) and (Save.ProjectCosts[ActPlayer,6]>0) then begin
  10583.                if Year mod 13=0 then begin
  10584.                   MAKEBORDER(MyScreen[1]^,100,100,410,180,12,6,0);
  10585.                   WRITE(256,110,ActPlayerFlag,0+16,MyScreen[1]^,4,'Wissenschaftler fordern');
  10586.                   WRITE(256,132,ActPlayerFlag,0+16,MyScreen[1]^,4,'Durchführung des');
  10587.                   WRITE(256,154,12,0+16,MyScreen[1]^,4,'GENESIS-Projects');
  10588.                   WAITLOOP(false);
  10589.                   RECT(MyScreen[1]^,0,100,100,410,180);
  10590.                   REFRESHDISPLAY;
  10591.                end;
  10592.             end else begin
  10593.                INFORMUSER;
  10594.                MAKEBORDER(MyScreen[1]^,60,100,368,267,12,6,0);
  10595.                WRITE(100,110,ActPlayerFlag,0,MyScreen[1]^,4,'Was soll entwickelt werden?');
  10596.                for j:=1 to 6 do if NewTech[j]>0 then WRITE(70,j*20+120,12,0,MyScreen[1]^,4,Technology[NewTech[j]]);
  10597.                i:=0;
  10598.                repeat
  10599.                   delay(RDELAY);
  10600.                   j:=(IBase^.MouseY-120) div 20;
  10601.                   if (i<>j) and (j in [1..6]) then begin
  10602.                      i:=j;
  10603.                      for j:=1 to 6 do if NewTech[j]>0 then WRITE(70,j*20+120,12,0,MyScreen[1]^,4,Technology[NewTech[j]]);
  10604.                      if NewTech[i]>0 then WRITE(70,i*20+120,ActPlayerFlag,0,MyScreen[1]^,4,Technology[NewTech[i]]);
  10605.                   end;
  10606.                   if (LData^ and 64=0) then begin
  10607.                      PLAYSOUND(1,300);
  10608.                      if i>0 then if NewTech[i]>0 then Save.ActTech[ActPlayer]:=NewTech[i];
  10609.                   end;
  10610.                until Save.ActTech[ActPlayer]>0;
  10611.                RECT(MyScreen[1]^,0,60,100,370,270);
  10612.                REFRESHDISPLAY;
  10613.             end;
  10614.          end;
  10615.       end;
  10616.       for i:=1 to pred(MAXCIVS) do begin
  10617.          if (ActPlayer=1) and ((i<8) or (Save.WorldFlag<>0)) then begin
  10618.             if Save.JSteuer[i]+Save.GSteuer[i]>100 then Save.GSteuer[i]:=100-Save.JSteuer[i];
  10619.             if Save.JSteuer[i]+Save.GSteuer[i]+Save.SService[i]>100 then Save.SService[i]:=0;
  10620.             if (Save.CivPlayer[i]=0) or Save.PlayMySelf then begin
  10621.                if ((Save.Staatstopf[i]<Militärausgaben[i]*7) or (Save.Staatstopf[i]<3000))
  10622.                and (Save.GSteuer[i]+Save.JSteuer[i]<90) then begin
  10623.                   Save.GSteuer[i]:=Save.GSteuer[i]+1;
  10624.                   if (Save.Staatstopf[i]<0) and (Save.GSteuer[i]+Save.JSteuer[i]+3<=100)
  10625.                    then Save.GSteuer[i]:=Save.GSteuer[i]+3;
  10626.                end else begin
  10627.                   if (Save.Staatstopf[i]>0) and (Save.GSteuer[i]>0) then Save.GSteuer[i]:=Save.GSteuer[i]-1;
  10628.                   if (Save.Staatstopf[i]>2500000) and (Save.GSteuer[i]>5) then Save.GSteuer[i]:=Save.GSteuer[i]-5;
  10629.                end;
  10630.                if (Save.Staatstopf[i]<-10000) and (Save.GSteuer[i]>20) then btx:=FINDMONEYPLANET(GETCIVFLAG(i),i);
  10631.                if (Save.Bevölkerung[i]<1000) and (Save.Staatstopf[i]<0) then Save.Staatstopf[i]:=0;
  10632.             end;
  10633.             for j:=1 to MAXCIVS do if (i<>j) and (Save.Bevölkerung[i]>Save.Bevölkerung[j]) then Save.ImperatorState[i]:=Save.ImperatorState[i]+2;
  10634.             if (Year mod 10=0) then DOINFLATION(i);
  10635.          end;
  10636.          if (Save.CivPlayer[i]=0) and (Save.CivPlayer[ActPlayer]<>0)
  10637.          and not Save.PlayMySelf then for j:=1 to pred(MAXCIVS) do if (j<>i)
  10638.          and (Save.WarState[j,i]=LEVEL_WAR) and (Save.WarState[j,ActPlayer]=LEVEL_WAR)
  10639.          and (not (Save.WarState[ActPlayer,i] in [LEVEL_WAR,LEVEL_ALLIANZ,LEVEL_UNKNOWN,LEVEL_NO_ALLIANZ]))
  10640.          then begin
  10641.             MAKEBORDER(MyScreen[1]^,85,120,425,265,12,6,0);
  10642.             s:=GETCIVNAME(i);
  10643.             WRITE(256,136,GETCIVFLAG(i),1+16,MyScreen[1]^,4,s);
  10644.             WRITE(256,156,12,1+16,MyScreen[1]^,4,'bieten Allianz gegen');
  10645.             s:=GETCIVNAME(j);
  10646.             WRITE(256,176,GETCIVFLAG(j),1+16,MyScreen[1]^,4,s);
  10647.             WRITE(256,196,12,1+16,MyScreen[1]^,4,'an');
  10648.             DrawImage(^MyScreen[1]^.RastPort,^GadImg1,105,225);
  10649.             DrawImage(^MyScreen[1]^.RastPort,^GadImg1,290,225);
  10650.             WRITE(162,227,8,16,MyScreen[1]^,4,'Annehmen');
  10651.             WRITE(348,227,8,16,MyScreen[1]^,4,'Ablehnen');
  10652.             repeat
  10653.                delay(RDELAY);
  10654.             until (LData^ and 64=0) and (IBase^.MouseX in [105..221,290..406]) and (IBase^.MouseY in [225..245]);
  10655.             if IBase^.MouseX in [105..221] then begin
  10656.                KLICKGAD(105,225);
  10657.                Save.WarState[i,ActPlayer]:=LEVEL_ALLIANZ;
  10658.                Save.WarState[ActPlayer,i]:=LEVEL_ALLIANZ
  10659.             end else begin
  10660.                KLICKGAD(290,225);
  10661.                Save.WarState[i,ActPlayer]:=LEVEL_NO_ALLIANZ;
  10662.                Save.WarState[ActPlayer,i]:=LEVEL_NO_ALLIANZ;
  10663.                if (i in [2,3]) and (random(3)=0) and (Save.WarPower[i]>Save.WarPower[ActPlayer])
  10664.                 then AUTOVERHANDLUNG(i,ActPlayer,ActSys,MODE_BELEIDIGUNG);
  10665.             end;
  10666.             RECT(MyScreen[1]^,0,85,120,425,265);
  10667.             REFRESHDISPLAY;
  10668.          end;
  10669.          if ((Save.Bevölkerung[i]=0) and not (Save.WarState[ActPlayer,i] in [LEVEL_DIED,LEVEL_UNKNOWN])
  10670.          and (i<8))
  10671.          or ((Save.Bevölkerung[8]=0) and (i=8) and not (Save.WorldFlag in [0,WFLAG_FIELD])) then begin
  10672.             Save.WarState[ActPlayer,i]:=LEVEL_DIED;
  10673.             Save.WarState[i,i]:=LEVEL_DIED;
  10674.             if Save.CivPlayer[ActPlayer]<>0 then begin
  10675.                INFORMUSER;
  10676.                MAKEBORDER(MyScreen[1]^,85,120,425,210,12,6,0);
  10677.                s:='Zivilisation der '+GETCIVNAME(i);
  10678.                WRITE(256,140,GETCIVFLAG(i),1+16,MyScreen[1]^,4,s);
  10679.                WRITE(256,165,12,1+16,MyScreen[1]^,4,'ist verschwunden.');
  10680.                if Save.PlayMySelf then delay(PAUSE);
  10681.                WAITLOOP(Save.PlayMySelf);
  10682.                RECT(MyScreen[1]^,0,85,120,425,210);
  10683.                REFRESHDISPLAY;
  10684.             end;
  10685.             if i=8 then begin
  10686.                for j:=1 to 8 do Save.JSteuer[j]:=0;
  10687.                Save.WorldFlag:=0;
  10688.             end;
  10689.             Save.JSteuer[i]:=0;
  10690.          end;
  10691.       end;
  10692.    end;
  10693.    randomize;
  10694.    l:=0;
  10695.    if (Save.WorldFlag=WFLAG_JAHADR) and not (Save.WarState[ActPlayer,8] in [LEVEL_WAR,LEVEL_COLDWAR])
  10696.    and (Year mod 5=0) then for i:=1 to (MAXCIVS-2) do if (l=0) and (i<>ActPlayer)
  10697.     and (Save.JSteuer[i]>0) and (Save.WarState[ActPlayer,i]=LEVEL_WAR) then begin
  10698.       if (Save.CivPlayer[ActPlayer]<>0) and not Save.PlayMySelf then begin
  10699.          MAKEBORDER(MyScreen[1]^,80,120,430,265,12,6,0);
  10700.          WRITE(256,136,FLAG_OTHER,1+16,MyScreen[1]^,4,'Das Dominion fordert die Einstellung');
  10701.          WRITE(256,156,FLAG_OTHER,1+16,MyScreen[1]^,4,'aller Feindseligkeiten gegen die');
  10702.          s:=GETCIVNAME(i)+' bei Zahlung von';
  10703.          WRITE(256,176,FLAG_OTHER,1+16,MyScreen[1]^,4,s);
  10704.          l:=abs(Year)*11;   s:='Reparationen in Höhe von '+intstr(l);
  10705.          WRITE(256,196,FLAG_OTHER,1+16,MyScreen[1]^,4,s);
  10706.          DrawImage(^MyScreen[1]^.RastPort,^GadImg1,105,225);
  10707.          DrawImage(^MyScreen[1]^.RastPort,^GadImg1,290,225);
  10708.          WRITE(162,227,8,16,MyScreen[1]^,4,'Annehmen');
  10709.          WRITE(348,227,8,16,MyScreen[1]^,4,'Ablehnen');
  10710.          repeat
  10711.             delay(RDELAY);
  10712.          until (LData^ and 64=0) and (IBase^.MouseX in [105..221,290..406]) and (IBase^.MouseY in [225..245]);
  10713.          if IBase^.MouseX in [105..221] then begin
  10714.             KLICKGAD(105,225);
  10715.             Save.Staatstopf[i]:=Save.Staatstopf[i]+l;
  10716.             Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]-l;
  10717.             GOTOPEACE(i,ActPlayer);
  10718.             if Save.JSteuer[ActPlayer] in [1..99]
  10719.              then Save.JSteuer[ActPlayer]:=Save.JSteuer[ActPlayer]+1;
  10720.          end else begin
  10721.             KLICKGAD(290,225);
  10722.             Save.WarState[8,ActPlayer]:=LEVEL_COLDWAR;
  10723.          end;
  10724.          RECT(MyScreen[1]^,0,80,120,430,265);
  10725.          REFRESHDISPLAY;
  10726.       end else if Save.CivPlayer[i]=0 then begin
  10727.          if Save.JSteuer[ActPlayer]>0 then begin
  10728.             GOTOPEACE(i,ActPlayer);
  10729.             if Save.JSteuer[ActPlayer] in [1..99]
  10730.              then Save.JSteuer[ActPlayer]:=Save.JSteuer[ActPlayer]+1;
  10731.             l:=1;
  10732.          end else begin
  10733.             Save.WarState[8,ActPlayer]:=LEVEL_WAR;
  10734.             Save.WarState[ActPlayer,8]:=LEVEL_WAR;
  10735.             l:=1;
  10736.          end;
  10737.       end;
  10738.    end;
  10739.    if (Save.WarState[8,ActPlayer]=LEVEL_WAR) or (Save.WarState[ActPlayer,8]=LEVEL_WAR)
  10740.     then Save.JSteuer[ActPlayer]:=0;
  10741.    AUTOSHIPTRAVEL(Display,MODE_ALL,NIL);
  10742.    if (Save.Staatstopf[ActPlayer]<(Militärausgaben[ActPlayer]*3)) and (Year mod 2=0)
  10743.    and (Save.CivPlayer[ActPlayer]<>0) and (Save.Staatstopf[ActPlayer]>=0)
  10744.    and not Save.PlayMySelf then begin
  10745.       INFORMUSER;
  10746.       REQUEST('Es droht die Zahlungsunfähigkeit!','Bitte Steuern erhöhen!',ActPlayerFlag,ActPlayerFlag);
  10747.    end;
  10748.    if Save.Staatstopf[ActPlayer]<0 then begin
  10749.       Save.Staatstopf[ActPlayer]:=round(Save.Staatstopf[ActPlayer]*1.1);
  10750.       if Save.CivPlayer[ActPlayer]<>0 then PRINTGLOBALINFOS(ActPlayer);
  10751.    end;
  10752.    if (Save.Staatstopf[ActPlayer] in [-1..-10000]) and
  10753.    (Save.CivPlayer[ActPlayer]<>0) and not Save.PlayMySelf then begin
  10754.       INFORMUSER;
  10755.       REQUEST('Es droht der endgültige Bankrott!','Bitte unbedingt Steuern erhöhen!',ActPlayerFlag,ActPlayerFlag);
  10756.    end;
  10757.    if Save.Staatstopf[ActPlayer]<-10000 then begin
  10758.       btx:=FINDMONEYPLANET(ActPlayerFlag,ActPlayer);
  10759.       if (btx>0) and (Save.CivPlayer[ActPlayer]<>0) then begin
  10760.          INFORMUSER;
  10761.          MAKEBORDER(MyScreen[1]^,35,110,475,210,12,6,0);
  10762.          WRITE(256,150,ActPlayerFlag,16,MyScreen[1]^,4,s);
  10763.          s:=GETCIVNAME(ActPlayer)+' haben Schulden!';
  10764.          WRITE(256,127,12,16,MyScreen[1]^,4,s);
  10765.          s:='kann '+Project[btx]+' nicht erhalten!';
  10766.          WRITE(256,175,12,16,MyScreen[1]^,4,s);
  10767.          if Save.PlayMySelf then delay(PAUSE);
  10768.          WAITLOOP(Save.PlayMySelf);
  10769.          RECT(MyScreen[1]^,0,35,110,475,210);
  10770.          REFRESHDISPLAY;
  10771.       end;
  10772.    end;
  10773.    if (Year>1973) and (Save.CivPlayer[ActPlayer]<>0) then begin
  10774.       if (Save.ImperatorState[ActPlayer]<700) and (Warnung[ActPlayer]=0) then begin
  10775.          INFORMUSER;
  10776.          MAKEBORDER(MyScreen[1]^,30,80,480,205,12,6,0);
  10777.          WRITE(256, 95,ActPlayerFlag,16,MyScreen[1]^,4,'Der äußerst aggressive Führungsstil des');
  10778.          WRITE(256,115,ActPlayerFlag,16,MyScreen[1]^,4,'Imperators löst großen Unmut bei der');
  10779.          WRITE(256,135,ActPlayerFlag,16,MyScreen[1]^,4,'Bevölkerung aus.');
  10780.          WRITE(256,155,ActPlayerFlag,16,MyScreen[1]^,4,'Es werden aus allen Provinzen und Kolonien');
  10781.          WRITE(256,175,ActPlayerFlag,16,MyScreen[1]^,4,'schwere Unruhen gemeldet!');
  10782.          Warnung[ActPlayer]:=1;
  10783.          Save.ImperatorState[ActPlayer]:=700;
  10784.          WAITLOOP(false);
  10785.          RECT(MyScreen[1]^,0,30,80,480,205);
  10786.          REFRESHDISPLAY;
  10787.       end else if (Save.ImperatorState[ActPlayer]<500) and (Warnung[ActPlayer]=1) then begin
  10788.          INFORMUSER;
  10789.          MAKEBORDER(MyScreen[1]^,30,80,480,185,12,6,0);
  10790.          WRITE(256, 95,ActPlayerFlag,16,MyScreen[1]^,4,'Der anhaltend brutale und faschistische');
  10791.          WRITE(256,115,ActPlayerFlag,16,MyScreen[1]^,4,'Führungsstil des Imperators verursacht');
  10792.          WRITE(256,135,ActPlayerFlag,16,MyScreen[1]^,4,'weitere Unruhen und offenen Aufruhr auf allen');
  10793.          WRITE(256,155,ActPlayerFlag,16,MyScreen[1]^,4,'Planeten des Imperiums!');
  10794.          Warnung[ActPlayer]:=2;
  10795.          WAITLOOP(false);
  10796.          RECT(MyScreen[1]^,0,30,80,480,185);
  10797.          REFRESHDISPLAY;
  10798.       end;
  10799.       if Save.ImperatorState[ActPlayer]>=1000 then Warnung[ActPlayer]:=0;
  10800.    end;
  10801.    {*** STATUSCHECK BÜRGERKRIEG ***}
  10802.    if (Year mod 4=0) and (Save.WorldFlag=ActPlayerFlag) then begin
  10803.       if Save.WarPower[8]>Save.WarPower[ActPlayer]*3 then STOPCIVILWAR(1)
  10804.       else if Save.WarPower[8]*3<Save.WarPower[ActPlayer] then STOPCIVILWAR(2)
  10805.       else if Save.Bevölkerung[8]+Save.Bevölkerung[ActPlayer]<100000 then STOPCIVILWAR(0);
  10806.    end;
  10807.    if (Save.WorldFlag=WFLAG_FIELD) and (ActPlayer=1) then begin
  10808.       if Save.SYSTEMS>1 then Save.SYSTEMS:=Save.SYSTEMS-1 else Save.Bevölkerung[ActPlayer]:=0;
  10809.       if Display>Save.SYSTEMS then DRAWSTARS(MODE_REDRAW,ActPlayer)
  10810.    end;
  10811.    {*** SPIELER SPIELT NICHT ***}
  10812.    if Save.WarPower[ActPlayer]>Save.MaxWarPower[ActPlayer] then Save.MaxWarPower[ActPlayer]:=Save.WarPower[ActPlayer];
  10813.    if Multiplayer and not Save.PlayMySelf
  10814.    and (Save.CivPlayer[ActPlayer]<>0) and (Year>2065) and (Save.MaxWarPower[ActPlayer]=0) then begin
  10815.       j:=0;
  10816.       for i:=1 to (MAXCIVS-2) do if Save.CivPlayer[i]<>0 then j:=j+1;
  10817.       if j>1 then begin
  10818.          INFORMUSER;
  10819.          MAKEBORDER(MyScreen[1]^,30,120,480,215,12,6,0);
  10820.          s:='Die '+GETCIVNAME(ActPlayer)+' trennen sich von Spieler '+intstr(Save.CivPlayer[ActPlayer])+',';
  10821.          WRITE(256,140,ActPlayerFlag,16,MyScreen[1]^,4,s);
  10822.          WRITE(256,160,ActPlayerFlag,16,MyScreen[1]^,4,'da dieser offenbar nicht in der Lage ist,');
  10823.          WRITE(256,180,ActPlayerFlag,16,MyScreen[1]^,4,'eine Zivilisation erfolgreich zu führen!');
  10824.          WAITLOOP(false);
  10825.          RECT(MyScreen[1]^,0,30,120,480,215);
  10826.          Save.CivPlayer[ActPlayer]:=0;
  10827.          Save.Staatstopf[ActPlayer]:=Save.Staatstopf[ActPlayer]+Year*120;
  10828.          for i:=1 to 7 do Save.TechCosts[ActPlayer,succ(random(30))]:=0;
  10829.          for i:=1 to pred(MAXCIVS) do begin
  10830.             if Save.WarState[i,ActPlayer] in [LEVEL_WAR,LEVEL_COLDWAR] then Save.WarState[i,ActPlayer]:=LEVEL_PEACE;
  10831.             if Save.WarState[ActPlayer,i] in [LEVEL_WAR,LEVEL_COLDWAR] then Save.WarState[ActPlayer,i]:=LEVEL_PEACE;
  10832.          end;
  10833.          CREATEJAHADR(ActPlayer);
  10834.       end;
  10835.    end;
  10836.  
  10837.    {*** WIEDERAUFERSTEHUNG ZIVI ***}
  10838.    if ((ActPlayer<>1) or Multiplayer) and (Save.WorldFlag<>WFLAG_CEBORC)
  10839.    and (ActPlayer<=(MAXCIVS-2)) and (Save.Bevölkerung[ActPlayer]<=0) then begin
  10840.       j:=succ(random(Save.SYSTEMS));
  10841.       if SystemFlags[1,j] and FLAG_CIV_MASK=0 then begin
  10842.          if SystemHeader[j].Planets=0 then CREATENEWSYSTEM(j,ActPlayer);
  10843.          for k:=0 to pred(SystemHeader[j].Planets) do if (Save.Bevölkerung[ActPlayer]=0)
  10844.          then begin
  10845.             PlanetHeader:=ptr(SystemHeader[j].PlanetMemA+sizeof(r_PlanetHeader)*k);
  10846.             if PlanetHeader^.Class in [CLASS_WATER,CLASS_ICE,CLASS_DESERT,CLASS_HALFEARTH,
  10847.             CLASS_STONES] then with PlanetHeader^ do begin
  10848.                SystemHeader[j].vNS:=0;
  10849.                Save.CivPlayer[ActPlayer]:=0;
  10850.                PName:=PNames[0,NewPNames];
  10851.                NewPNames:=NewPNames+1;
  10852.                if NewPNames>MAXPLANETS then NewPNames:=1;
  10853.                PlanetHeader^.PFlags:=ActPlayerFlag; Ethno:=PFlags;
  10854.                Population:=abs(Year*5);
  10855.                if Population>Size*500 then Population:=Size*500;
  10856.                Save.Bevölkerung[ActPlayer]:=PlanetHeader^.Population;
  10857.                Biosphäre:=200;
  10858.                Infrastruktur:=190;
  10859.                Industrie:=180;
  10860.                ProjectPtr:=ptr(AllocMem(sizeof(ByteArr42),MEMF_CLEAR));
  10861.                ProjectPtr^[1]:=1;
  10862.                ProjectPtr^[26]:=5;
  10863.                for i:=1 to pred(MAXCIVS) do if i<>ActPlayer then begin
  10864.                   Save.WarState[ActPlayer,i]:=LEVEL_UNKNOWN;
  10865.                   Save.WarState[i,ActPlayer]:=LEVEL_UNKNOWN;
  10866.                end;
  10867.                Save.WarState[ActPlayer,ActPlayer]:=LEVEL_PEACE;
  10868.             end;
  10869.          end;
  10870.          if (Year<2120) and (random(45)=0) then CREATEJAHADR(ActPlayer)
  10871.          else if (Year>2120) and (random(255)=0) then JAHADRINVASION(ActPlayer);
  10872.       end;
  10873.    end;
  10874.    if (random(219)=0) and (random(219)=0) then CEBORCATTACK(0);
  10875.    if (random(219)=0) and (random(219)=0) then JAHADRINVASION(ActPlayer);
  10876.    if (random(240)=0) and (random(50)=0) then begin
  10877.       l:=0;
  10878.       for i:=1 to (MAXCIVS-2) do
  10879.        if (i<>ActPlayer) and (Save.WarState[ActPlayer,1]<>LEVEL_UNKNOWN) then l:=1;
  10880.       if l=0 then CREATEJAHADR(ActPlayer);
  10881.    end;
  10882. end; {ROTATEPLANETS}
  10883.  
  10884.  
  10885.  
  10886. procedure STARTROTATEPLANETS(ActSys :byte);
  10887. forward;
  10888.  
  10889.  
  10890.  
  10891. procedure HANDLESYSTEM(ActSys :byte; ShipPtr :ptr);
  10892.  
  10893. var i                   :integer;
  10894. var MyShipPtr           :^r_ShipHeader;
  10895. var MyPlanetHeader      :^r_PlanetHeader;
  10896.  
  10897.  
  10898.  
  10899. procedure SEARCHOBJECT;
  10900.  
  10901. var PSys,PNum,PCol      :array [1..37] of byte;
  10902. var ShipPos             :array [1..37] of ^r_ShipHeader;
  10903. var y,z                 :integer;
  10904. var LastSys             :byte;
  10905. var MyPlanet            :^r_PlanetHeader;
  10906. var MyShipPtr           :^r_ShipHeader;
  10907. var ThisP,LastP         :byte;
  10908. var Mode                :short;
  10909. var b                   :boolean;
  10910. var sx                  :str;
  10911. var s                   :string;
  10912.  
  10913.  
  10914. procedure DRAWSHIPS(CivFlag,stSys :byte);
  10915.  
  10916. var i,j         :byte;
  10917.  
  10918. begin
  10919.    RECT(MyScreen[1]^,0,0,0,511,511);
  10920.    y:=0;   z:=0;
  10921.    for i:= 1 to 35 do PSys[i]:=0;
  10922.    for i:=36 to 37 do PSys[i]:=1;
  10923.    for i:=stSys to Save.SYSTEMS do
  10924.    if (SystemFlags[ActPlayer,i] and FLAG_KNOWN=FLAG_KNOWN) then with SystemHeader[i] do begin
  10925.       MyShipPtr:=SystemHeader[i].FirstShip.NextShip;
  10926.       while MyShipPtr<>NIL do begin
  10927.          if (MyShipPtr^.Owner=ActPlayerFlag) and
  10928.          (((Mode=-1) and (MyShipPtr^.Target=TARGET_POSITION)) or
  10929.          ((Mode=-2) and (MyShipPtr^.Flags=SHIPFLAG_WATER) and (MyShipPtr^.Moving>=0)))
  10930.          then begin
  10931.             z:=z+1;
  10932.             if z=36 then begin
  10933.                LastSys:=i;
  10934.                WRITE(100,497,12,0,MyScreen[1]^,3,sx);
  10935.                exit;
  10936.             end;
  10937.             ShipPos[z]:=MyShipPtr; PSys[z]:=i;
  10938.             with MyShipPtr^ do begin
  10939.                if SType=SHIPTYPE_FLEET then begin
  10940.                   s:='Flotte';
  10941.                   WRITE(40,y,ActPlayerFlag,0,MyScreen[1]^,3,s);
  10942.                end else begin
  10943.                   s:=Project[SType];
  10944.                   WRITE(40,y,ActPlayerFlag,0,MyScreen[1]^,3,s);
  10945.                   s:='Siedler: '+intstr((Ladung and MASK_SIEDLER) div 16);
  10946.                   WRITE(135,y,12,0,MyScreen[1]^,3,s);
  10947.                   s:='Landungstrupps: '+intstr(Ladung and MASK_LTRUPPS);
  10948.                   WRITE(230,y,12,0,MyScreen[1]^,3,s);
  10949.                   s:='Beladung: '+intstr(round(Fracht / ShipData[Stype].MaxLoad*100))+' %';
  10950.                   WRITE(365,y,12,0,MyScreen[1]^,3,s);
  10951.                end;
  10952.             end;
  10953.             y:=y+14;
  10954.          end;
  10955.          MyShipPtr:=MyShipPtr^.NextShip;
  10956.       end;
  10957.    end;
  10958.    LastSys:=1;
  10959.    WRITE(100,497,12,0,MyScreen[1]^,3,sx);
  10960. end;
  10961.  
  10962.  
  10963.  
  10964. procedure DRAWPLANETS(CivFlag,stSys :byte);
  10965.  
  10966. var i,j         :byte;
  10967.  
  10968. begin
  10969.    RECT(MyScreen[1]^,0,0,0,511,511);
  10970.    y:=0;   z:=0;
  10971.    for i:= 1 to 35 do PSys[i]:=0;
  10972.    for i:=36 to 37 do PSys[i]:=1;
  10973.    for i:=stSys to Save.SYSTEMS do
  10974.     if (SystemFlags[ActPlayer,i] and FLAG_KNOWN=FLAG_KNOWN) then with SystemHeader[i] do for j:=1 to Planets do begin
  10975.       MyPlanet:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  10976.       with MyPlanet^ do if ((PFlags and FLAG_CIV_MASK=CivFlag) and (CivFlag<>0)) or
  10977.       ((CivFlag=0) and not (PFlags and FLAG_CIV_MASK=ActPlayerFlag) and (PFlags>0)) then begin
  10978.          z:=z+1;
  10979.          if z=36 then begin
  10980.             LastSys:=i;
  10981.             WRITE(100,497,12,0,MyScreen[1]^,3,sx);
  10982.             exit;
  10983.          end;
  10984.          PSys[z]:=i; PNum[z]:=j; PCol[z]:=PFlags and FLAG_CIV_MASK;
  10985.          if PCol[z]=0 then PCol[z]:=1;
  10986.          WRITE(50,y,PCol[z],0,MyScreen[1]^,3,PName);
  10987.          if CivFlag=ActPlayerFlag then begin
  10988.             case ProjectID of
  10989.                -3: s:='Biosphäre reinigen';
  10990.                -2: s:='Infrastruktur reparieren';
  10991.                -1: s:='Industrie aufbauen';
  10992.                 0: s:='---';
  10993.                 otherwise s:=Project[ProjectID];
  10994.             end;
  10995.             WRITE(170,y,12,0,MyScreen[1]^,3,s);
  10996.             s:=intstr(Population)+' Mio';
  10997.             WRITE(465,y,12,32,MyScreen[1]^,3,s);
  10998.          end else begin
  10999.             s:='Größe: '+realstr(Size/10,2);
  11000.             WRITE(170,y,12,0,MyScreen[1]^,3,s);
  11001.             if Ethno=ActPlayerFlag then begin
  11002.                s:=GETCIVADJ(ActPlayer)+' Minderheit';
  11003.                WRITE(350,y,12,0,MyScreen[1]^,3,s);
  11004.             end;
  11005.          end;
  11006.          y:=y+14;
  11007.       end;
  11008.    end;
  11009.    LastSys:=1;
  11010.    WRITE(100,497,12,0,MyScreen[1]^,3,sx);
  11011. end;
  11012.  
  11013.  
  11014.  
  11015. begin
  11016.    ThisP:=1; LastP:=1; LastSys:=1;
  11017.    sx:='Nächste Seite     >>>';
  11018.    MAKEBORDER(MyScreen[1]^,194,119,316,254,12,6,1);
  11019.    for i:=2 to 3 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  11020.    for i:=5 to 6 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  11021.    WRITE(255,124,12,16,MyScreen[1]^,4,'Planeten');
  11022.    WRITE(255,146,0,16,MyScreen[1]^,4,'eigene');
  11023.    WRITE(255,168,0,16,MyScreen[1]^,4,'fremde');
  11024.    WRITE(255,190,12,16,MyScreen[1]^,4,'Schiffe');
  11025.    WRITE(255,212,0,16,MyScreen[1]^,4,'Position');
  11026.    WRITE(255,234,0,16,MyScreen[1]^,4,'Bewässern');
  11027.    b:=false;
  11028.    repeat
  11029.       delay(RDELAY);
  11030.       if (LData^ and 64=0) then begin
  11031.          if IBase^.MouseX in [196..314] then begin
  11032.             if IBase^.MouseY in [144..164] then begin
  11033.                KLICKGAD(198,144);
  11034.                Mode:=ActPlayerFlag;
  11035.                b:=true;
  11036.             end else if IBase^.MouseY in [166..186] then begin
  11037.                KLICKGAD(198,166);
  11038.                Mode:=0;
  11039.                b:=true;
  11040.             end else if IBase^.MouseY in [210..230] then begin
  11041.                KLICKGAD(198,210);
  11042.                Mode:=-1;
  11043.                b:=true;
  11044.             end else if IBase^.MouseY in [232..252] then begin
  11045.                KLICKGAD(198,232);
  11046.                Mode:=-2;
  11047.                b:=true;
  11048.             end;
  11049.          end
  11050.       end;
  11051.    until b or (RData^ and 1024=0);
  11052.    if RData^ and 1024=0 then begin
  11053.       PLAYSOUND(1,300);
  11054.       RECT(MyScreen[1]^,0,194,119,316,254);
  11055.       REFRESHDISPLAY;
  11056.       exit;
  11057.    end;
  11058.    b:=false;
  11059.    if Mode<0 then begin
  11060.       repeat
  11061.          delay(RDELAY);
  11062.          DRAWSHIPS(Mode,1);
  11063.          repeat
  11064.             delay(RDELAY);
  11065.             repeat
  11066.                delay(RDELAY);
  11067.                ThisP:=succ(IBase^.MouseY div 14);
  11068.                if (PSys[ThisP]<>0) and (ThisP<>LastP) and (IBase^.MouseX in [0..511]) then begin
  11069.                   if (LastP<36) and (PSys[LastP]<>0) then begin
  11070.                      MyShipPtr:=ShipPos[LastP];
  11071.                      if ShipPos[LastP]^.SType=SHIPTYPE_FLEET
  11072.                      then s:='Flotte' else s:=Project[ShipPos[LastP]^.SType];
  11073.                      WRITE(40,pred(LastP)*14,ActPlayerFlag,1,MyScreen[1]^,3,s);
  11074.                   end else WRITE(100,497,12,1,MyScreen[1]^,3,sx);
  11075.                   if ThisP<36 then begin
  11076.                      MyShipPtr:=ShipPos[ThisP];
  11077.                      if ShipPos[ThisP]^.SType=SHIPTYPE_FLEET
  11078.                      then s:='Flotte' else s:=Project[ShipPos[ThisP]^.SType];
  11079.                      WRITE(40,pred(ThisP)*14,ActPlayerFlag,5,MyScreen[1]^,3,s);
  11080.                   end else WRITE(100,497,12,5,MyScreen[1]^,3,sx);
  11081.                   LastP:=ThisP;
  11082.                end else ThisP:=LastP;
  11083.             until (RData^ and 1024=0) or (LData^ and 64=0);
  11084.             if (LData^ and 64=0) then begin
  11085.                PLAYSOUND(1,300);
  11086.                if ThisP>=36 then DRAWSHIPS(Mode,LastSys) else begin
  11087.                   if PSys[ThisP]<>0 then begin
  11088.                      OffsetX:=-ShipPos[ThisP]^.PosX-1;
  11089.                      OffsetY:=-ShipPos[ThisP]^.PosY-1;
  11090.                      ActSys:=PSys[ThisP];
  11091.                   end;
  11092.                   DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11093.                   b:=true;
  11094.                end;
  11095.             end;
  11096.          until (RData^ and 1024=0) or b;
  11097.       until (RData^ and 1024=0) or b;
  11098.    end else begin
  11099.       repeat
  11100.          delay(RDELAY);
  11101.          DRAWPLANETS(Mode,1);
  11102.          repeat
  11103.             delay(RDELAY);
  11104.             repeat
  11105.                delay(RDELAY);
  11106.                ThisP:=succ(IBase^.MouseY div 14);
  11107.                if (PSys[ThisP]<>0) and (ThisP<>LastP) and (IBase^.MouseX in [0..511]) then begin
  11108.                   if (LastP<36) and (PSys[LastP]<>0) then begin
  11109.                      MyPlanet:=ptr(SystemHeader[PSys[LastP]].PlanetMemA+pred(PNum[LastP])*sizeof(r_PlanetHeader));
  11110.                      WRITE(50,pred(LastP)*14,PCol[LastP],1,MyScreen[1]^,3,MyPlanet^.PName);
  11111.                   end else WRITE(100,497,12,1,MyScreen[1]^,3,sx);
  11112.                   if ThisP<36 then begin
  11113.                      MyPlanet:=ptr(SystemHeader[PSys[ThisP]].PlanetMemA+pred(PNum[ThisP])*sizeof(r_PlanetHeader));
  11114.                      WRITE(50,pred(ThisP)*14,PCol[ThisP],5,MyScreen[1]^,3,MyPlanet^.PName);
  11115.                   end else WRITE(100,497,12,5,MyScreen[1]^,3,sx);
  11116.                   LastP:=ThisP;
  11117.                end else ThisP:=LastP;
  11118.             until (RData^ and 1024=0) or (LData^ and 64=0);
  11119.             if (LData^ and 64=0) then begin
  11120.                PLAYSOUND(1,300);
  11121.                if ThisP>=36 then DRAWPLANETS(Mode,LastSys) else begin
  11122.                   if PSys[ThisP]<>0 then begin
  11123.                      OffsetX:=-round(MyPlanet^.PosX)-1;
  11124.                      OffsetY:=-round(MyPlanet^.PosY)-1;
  11125.                      ActSys:=PSys[ThisP];
  11126.                   end;
  11127.                   DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11128.                   b:=true;
  11129.                end;
  11130.             end;
  11131.          until (RData^ and 1024=0) or b;
  11132.       until (RData^ and 1024=0) or b;
  11133.    end;
  11134.    if RData^ and 1024=0 then begin
  11135.       PLAYSOUND(1,300);
  11136.       DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11137.    end;
  11138. end;
  11139.  
  11140.  
  11141.  
  11142. begin
  11143.    OffsetX:=0; OffsetY:=0;
  11144.    if Display<>ActSys then DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11145.    repeat
  11146.       delay(RDELAY);
  11147.       ScreenToFront(MyScreen[1]);
  11148.       CLOCK;
  11149.       RawCode:=GETRAWCODE;
  11150.       if (Save.PlayMySelf) or (Save.CivPlayer[ActPlayer]=0) or not Informed
  11151.       or (not Multiplayer and not Informed and (Year mod 10<>0)) then STARTROTATEPLANETS(ActSys) else begin
  11152.          if (LData^ and 64=0) or (RData^ and 1024=0) then delay(3);
  11153.          if ((LData^ and 64=0) and (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [472..492]))
  11154.           or ((LData^ and 64=0) and (RData^ and 1024=0)) or (RawCode in [64,67,68]) then begin
  11155.             KLICKGAD(518,472);
  11156.             STARTROTATEPLANETS(ActSys);
  11157.          end;
  11158.  
  11159.          if (LData^ and 64=0) and not Save.PlayMySelf then begin
  11160.             if IBase^.MouseX in [518..634] then begin
  11161.                if IBase^.MouseY in [9..117] then begin
  11162.                   PLAYSOUND(1,300);
  11163.                   OffsetX:=576-IBase^.MouseX; OffsetY:=63-IBase^.MouseY;
  11164.                   DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11165.                end else if IBase^.MouseY in [416..436] then begin
  11166.                   KLICKGAD(518,416);
  11167.                   SEARCHOBJECT;
  11168.                end;
  11169.             end else if (IBase^.MouseX in [0..511]) and (IBase^.MouseY in [0..511]) then begin
  11170.                PLAYSOUND(1,300);
  11171.                if FINDOBJECT(ActSys,IBase^.MouseX,IBase^.MouseY,NIL) then case ObjType of
  11172.                   TYPE_PLANET:   PLANETINFO(ActSys);
  11173.                   TYPE_SHIP:     begin
  11174.                                     MyShipPtr:=ObjPtr;
  11175.                                     if MyShipPtr^.SType=SHIPTYPE_FLEET then ORBITINFO(MyShipPtr,'Flotte',ActSys,0,0)
  11176.                                     else SHIPINFO(ActSys);
  11177.                                  end;
  11178.                   otherwise;
  11179.                end;
  11180.             end;
  11181.          end else if (RData^ and 1024=0) then begin
  11182.             if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [9..117]) then begin
  11183.                if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [9..29]) then
  11184.                 if OffsetY<42 then OffsetY:=OffsetY+2;
  11185.                if (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [97..117]) then
  11186.                 if OffsetY>-42 then OffsetY:=OffsetY-2;
  11187.                if (IBase^.MouseX in [518..538]) and (IBase^.MouseY in [9..117]) then
  11188.                 if OffsetX<42 then OffsetX:=OffsetX+2;
  11189.                if (IBase^.MouseX in [614..634]) and (IBase^.MouseY in [9..117]) then
  11190.                 if OffsetX>-42 then OffsetX:=OffsetX-2;
  11191.                DRAWSYSTEM(MODE_REDRAW,ActSys,NIL);
  11192.             end;
  11193.             if (IBase^.MouseX in [0..511]) and (IBase^.MouseY in [0..511]) then begin
  11194.                PLAYSOUND(1,300);
  11195.                if FINDOBJECT(ActSys,IBase^.MouseX,IBase^.MouseY,NIL) then case ObjType of
  11196.                   TYPE_PLANET:   begin
  11197.                                     MyPlanetHeader:=ObjPtr;
  11198.                                     s:='Standardorbit '+MyPlanetHeader^.PName;
  11199.                                     with MyPlanetHeader^ do ORBITINFO(FirstShip.NextShip,s,ActSys,round(PosX),round(PosY));
  11200.                                  end;
  11201.                   TYPE_SHIP:     SYSTEMINFO(ActSys);
  11202.                   otherwise;
  11203.                end;
  11204.             end;
  11205.          end;
  11206.       end;
  11207.       CLEARINTUITION;
  11208.    until (Display=0) or (SystemFlags[ActPlayer,ActSys] and FLAG_KNOWN=0)
  11209.    or ((LData^ and 64=0) and (IBase^.MouseX in [518..634]) and  (IBase^.MouseY in [444..464]))
  11210.    or Save.PlayMySelf;
  11211.    if Display<>0 then begin
  11212.       KLICKGAD(518,444);
  11213.       RECT(MyScreen[1]^,0,522,9,629,117);
  11214.       DRAWSTARS(MODE_REDRAW,ActPlayer)
  11215.    end;
  11216. end;
  11217.  
  11218.  
  11219.  
  11220. procedure STARTROTATEPLANETS;
  11221.  
  11222. var i,j,PredPlayer      :byte;
  11223. var s                   :string;
  11224.  
  11225.  
  11226. procedure CREATEINFOBOX;
  11227.  
  11228. var s           :string;
  11229.  
  11230. begin
  11231.    INFORMUSER;
  11232.    MAKEBORDER(MyScreen[1]^,30,100,480,270,12,6,0);
  11233.    s:='Ereignisse '+intstr(Year)+':';
  11234.    WRITE(255,110,ActPlayerFlag,16,MyScreen[1]^,4,s);
  11235.    PRINTGLOBALINFOS(ActPlayer);
  11236. end;
  11237.  
  11238.  
  11239. begin
  11240.    for i:=1 to MAXCIVS do Save.LastWarState[ActPlayer,i]:=Save.WarState[ActPlayer,i];
  11241.    if Informed then LastDisplay[ActPlayer]:=Display;
  11242.    ActPlayer:=ActPlayer+1;
  11243.    if ActPlayer>MAXCIVS then ActPlayer:=1;
  11244.    ActPlayerFlag:=GETCIVFLAG(ActPlayer);
  11245.    if Display<>0 then DRAWSTARS(MODE_REDRAW,ActPlayer);
  11246.    Informed:=false;
  11247.    j:=1;
  11248.    if (Year>1900) and (Save.CivPlayer[ActPlayer]<>0) then begin
  11249.       if (Save.WarState[ActPlayer,ActPlayer]<>LEVEL_DIED) then for i:=1 to pred(MAXCIVS) do begin
  11250.          if Save.LastWarState[ActPlayer,i]<>Save.WarState[ActPlayer,i] then begin
  11251.             j:=j+1;
  11252.             if Save.WarState[ActPlayer,i]=LEVEL_DIED then s:='Zivilisation der '+GETCIVNAME(i)+' ist verschwunden'
  11253.             else if (Save.WarState[ActPlayer,i]=LEVEL_PEACE)
  11254.              and (Save.LastWarState[ActPlayer,i]=LEVEL_WAR) then s:=GETCIVNAME(i)+' haben Friedensvertrag unterschrieben'
  11255.             else if Save.WarState[ActPlayer,i]=LEVEL_WAR then s:=GETCIVNAME(i)+' haben Krieg gegen '+GETCIVNAME(ActPlayer)+' begonnen'
  11256.             else if Save.WarState[ActPlayer,i]=LEVEL_ALLIANZ then s:=GETCIVNAME(i)+' haben Bündnis mit '+GETCIVNAME(ActPlayer)+'n geschlossen'
  11257.             else j:=j-1;
  11258.          end;
  11259.          if j>1 then begin
  11260.             if not Informed then CREATEINFOBOX;
  11261.             WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11262.          end;
  11263.       end;
  11264.       if (Save.WarState[ActPlayer,8]=LEVEL_PEACE)
  11265.       and (Save.LastWarState[ActPlayer,8]=LEVEL_UNKNOWN)
  11266.       and (Save.WorldFlag in [FLAG_TERRA,FLAG_KLEGAN,FLAG_REMALO,FLAG_CARDAC,
  11267.       FLAG_FERAGI,FLAG_BAROJA,FLAG_VOLKAN]) then begin
  11268.          if not Informed then CREATEINFOBOX;
  11269.          j:=j+1;
  11270.          s:=GETCIVNAME(FLAG_OTHER)+' spalten sich in zwei Teile und';
  11271.          if not Informed then CREATEINFOBOX;
  11272.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11273.          j:=j+1;
  11274.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'geraten in einen Bürgerkrieg!');
  11275.       end;
  11276.       if (ActPlayer=7) and (Save.CivilWar<>0) and
  11277.       (Save.WarState[Save.CivilWar,8]=Save.LastWarState[Save.CivilWar,8]) then Save.CivilWar:=0;
  11278.       if Save.CivilWar<>0 then if (Save.WarState[Save.CivilWar,8]=LEVEL_UNKNOWN)
  11279.       and (Save.LastWarState[Save.CivilWar,8]=LEVEL_WAR)
  11280.       and (GETCIVVAR(Save.WorldFlag) in [1..7]) then begin
  11281.          j:=j+1;
  11282.          s:=GETCIVNAME(FLAG_OTHER)+' beenden den Bürgerkrieg';
  11283.          if not Informed then CREATEINFOBOX;
  11284.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11285.       end;
  11286.  
  11287.       if GetPlanetSys[ActPlayer]<>0 then begin
  11288.          j:=j+1;
  11289.          s:='Planet '+GetPlanet[ActPlayer]^.PName+' ';
  11290.          case ActPlayer of
  11291.             FLAG_TERRA:  s:=s+'ist in Föderation übergetreten';
  11292.             FLAG_KLEGAN: s:=s+'ist ins Reich übergetreten';
  11293.             FLAG_FERAGI: s:=s+'ist in die Allianz übergetreten';
  11294.             otherwise s:=s+'ist ins Imperium übergetreten';
  11295.          end;
  11296.          if not Informed then CREATEINFOBOX;
  11297.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11298.       end;
  11299.       if Verschrottung[ActPlayer]>0 then begin
  11300.          j:=j+1;
  11301.          if Verschrottung[ActPlayer]>1 then s:=intstr(Verschrottung[ActPlayer])+' Schiffe wurden verschrottet'
  11302.          else s:='1 Schiff wurde verschrottet';
  11303.          if not Informed then CREATEINFOBOX;
  11304.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11305.          Verschrottung[ActPlayer]:=0;
  11306.       end;
  11307.       if vNSonde[ActPlayer] then begin
  11308.          j:=j+1;
  11309.          s:=GETCIVNAME(ActPlayer)+' entdecken unbekannte Sonde';
  11310.          if not Informed then CREATEINFOBOX;
  11311.          WRITE(255,100+j*18,12,16,MyScreen[1]^,4,s);
  11312.          vNSonde[ActPlayer]:=false;
  11313.       end;
  11314.    end;
  11315.    if (Year=1963) and (Save.CivPlayer[ActPlayer]<>0)
  11316.    and (random(10)=0) then begin
  11317.       j:=j+2;
  11318.       if not Informed then CREATEINFOBOX;
  11319.       WRITE(255,100+pred(j)*18,12,16,MyScreen[1]^,4,'Auf der Erde nimmt Dank Gene Roddenberry');
  11320.       WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'eine Legende ihren Anfang!');
  11321.    end;
  11322.    if (Year=1973) and (Save.CivPlayer[ActPlayer]<>0)
  11323.    and (random(10)=0) then begin
  11324.       j:=j+2;
  11325.       if not Informed then CREATEINFOBOX;
  11326.       WRITE(255,100+pred(j)*18,12,16,MyScreen[1]^,4,'Auf der Erde wird ein');
  11327.       WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'genialer Programmierer geboren!');
  11328.    end;
  11329.    if (Year=2001) and (Save.CivPlayer[ActPlayer]<>0)
  11330.    and (random(10)=0) then begin
  11331.       j:=j+2;
  11332.       if not Informed then CREATEINFOBOX;
  11333.       WRITE(255,100+pred(j)*18,12,16,MyScreen[1]^,4,'Stanley Kubricks & Arthur C. Clarkes');
  11334.       WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'Vision wird Wirklichkeit!');
  11335.    end;
  11336.    if (Year=2010) and (Save.CivPlayer[ActPlayer]<>0)
  11337.    and (random(10)=0) then begin
  11338.       j:=j+2;
  11339.       if not Informed then CREATEINFOBOX;
  11340.       WRITE(255,100+pred(j)*18,12,16,MyScreen[1]^,4,'Peter Hyams & Arthur C. Clarkes');
  11341.       WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'Vision wird Wirklichkeit!');
  11342.    end;
  11343.    if (Year=2063) and (Save.CivPlayer[ActPlayer]<>0)
  11344.    and (random(10)=0) then begin
  11345.       j:=j+2;
  11346.       if not Informed then CREATEINFOBOX;
  11347.       WRITE(255,100+pred(j)*18,12,16,MyScreen[1]^,4,'Auf der Erde findet');
  11348.       WRITE(255,100+j*18,12,16,MyScreen[1]^,4,'"Der erste Kontakt" statt!');
  11349.    end;
  11350.    if j>1 then begin
  11351.       if Save.PlayMySelf then delay(PAUSE);
  11352.       WAITLOOP(Save.PlayMySelf);
  11353.       RECT(MyScreen[1]^,0,30,100,480,270);
  11354.       REFRESHDISPLAY;
  11355.       if GetPlanetSys[ActPlayer]<>0 then begin
  11356.          if not Save.PlayMySelf and (Save.CivPlayer[ActPlayer]<>0)
  11357.           then HANDLEKNOWNPLANET(GetPlanetSys[ActPlayer],0,GetPlanet[ActPlayer]);
  11358.       end;
  11359.    end;
  11360.    GetPlanetSys[ActPlayer]:=0;
  11361.    ROTATEPLANETS(Display);
  11362.    if Informed then begin
  11363.       if (LastDisplay[ActPlayer]=0) and (Display<>0) then DRAWSTARS(MODE_REDRAW,ActPlayer)
  11364.       else if (LastDisplay[ActPlayer]<>0) then HANDLESYSTEM(LastDisplay[ActPlayer],NIL);
  11365.    end;
  11366.    if (Save.CivPlayer[ActPlayer]<>0) and Informed then begin
  11367.       RECT(MyScreen[1]^,0,520,291,632,308);
  11368.       WRITE(521,292,12,1,MyScreen[1]^,4,'Fertig');
  11369.    end;
  11370. end;
  11371.  
  11372.  
  11373.  
  11374. function INITSTARS:boolean;
  11375.  
  11376. type StrArrMAXP=array[1..MAXPLANETS] of string[20];
  11377.  
  11378. var l,m,HomePlanetProd  :long;
  11379. var b                   :boolean;
  11380. var PMemA               :array [1..MAXCIVS-2,1..5] of long;
  11381. var i,j,k               :integer;
  11382. var sin_rot,cos_rot,d   :real;
  11383. var PlanetHeader        :^r_PlanetHeader;
  11384. var ActPProjects        :^ByteArr42;
  11385. var DefaultShip         :r_ShipHeader;
  11386.  
  11387. begin
  11388.    INITSTARS:=false;
  11389.    randomize;
  11390.    SystemFlags[1,1]:=FLAG_TERRA+FLAG_KNOWN;
  11391.    for i:=1 to MAXCIVS-2 do for j:=1 to HomePlanets do begin
  11392.       PMemA[i,j]:=AllocMem(sizeof(ByteArr42),MEMF_CLEAR);
  11393.       if PMemA[i,j]=0 then exit;
  11394.       ActPProjects:=ptr(PMemA[i,j]);
  11395.       ActPProjects^[0]:=1;
  11396.    end;
  11397.    DefaultShip:=r_ShipHeader(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NIL,NIL,NIL);
  11398.    for i:=1 to MAXSYSTEMS do SystemHeader[i]:=r_SystemHeader(0,0,DefaultShip,0,0,0);
  11399.    with SystemHeader[1] do begin
  11400.       FirstShip.Owner:=FLAG_TERRA;
  11401.       Planets:=9;
  11402.       FirstShip:=DefaultShip;
  11403.       PlanetMemA:=AllocMem(Planets*sizeof(r_PlanetHeader),MEMF_CLEAR);
  11404.       if PlanetMemA=0 then exit;
  11405.       PlanetHeader:=ptr(PlanetMemA);
  11406.       PlanetHeader^:=r_PlanetHeader(CLASS_DESERT,2,FLAG_UNKNOWN,0,PNames[1,1],4,4,0,24,0,0,0,0,0,0,DefaultShip,NIL);
  11407.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader));
  11408.       PlanetHeader^:=r_PlanetHeader(CLASS_HALFEARTH,7,FLAG_UNKNOWN,0,PNames[1,2],7,7,0,283,0,0,0,0,0,0,DefaultShip,NIL);
  11409.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*2);
  11410.       PlanetHeader^:=r_PlanetHeader(CLASS_EARTH,10,FLAG_TERRA,FLAG_TERRA,PNames[1,3],10,10,4000,760,170,165,160,0,0,0,DefaultShip,ptr(PMemA[1,1]));
  11411.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*3);
  11412.       PlanetHeader^:=r_PlanetHeader(CLASS_DESERT,5,FLAG_UNKNOWN,0,PNames[1,4],13,13,0,61,0,0,0,0,0,0,DefaultShip,NIL);
  11413.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*4);
  11414.       PlanetHeader^:=r_PlanetHeader(CLASS_GAS,115,FLAG_UNKNOWN,0,PNames[1,5],16,16,0,0,0,0,0,0,0,0,DefaultShip,NIL);
  11415.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*5);
  11416.       PlanetHeader^:=r_PlanetHeader(CLASS_SATURN,82,FLAG_UNKNOWN,0,PNames[1,6],19,19,0,0,0,0,0,0,0,0,DefaultShip,NIL);
  11417.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*6);
  11418.       PlanetHeader^:=r_PlanetHeader(CLASS_GAS,41,FLAG_UNKNOWN,0,PNames[1,7],22,22,0,0,0,0,0,0,0,0,DefaultShip,NIL);
  11419.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*7);
  11420.       PlanetHeader^:=r_PlanetHeader(CLASS_GAS,45,FLAG_UNKNOWN,0,PNames[1,8],25,25,0,0,0,0,0,0,0,0,DefaultShip,NIL);
  11421.       PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*8);
  11422.       PlanetHeader^:=r_PlanetHeader(CLASS_DESERT,1,FLAG_UNKNOWN,0,PNames[1,9],30,30,0,11,0,0,0,0,0,0,DefaultShip,NIL);
  11423.       SystemHeader[1].SysOwner:=FLAG_TERRA;
  11424.       HomePlanetProd:=0;
  11425.       if HomePlanets>1 then begin
  11426.          l:=Homeplanets;
  11427.          for j:=0 to pred(Planets) do begin
  11428.             PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*j);
  11429.             if PlanetHeader^.Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,
  11430.             CLASS_WATER,CLASS_STONES,CLASS_ICE] then begin
  11431.                if (l>0) and ((l>1) or (j>1)) then with PlanetHeader^ begin
  11432.                   PFlags:=FLAG_TERRA;  Ethno:=PFlags;
  11433.                   PlanetHeader^.Water:=PlanetHeader^.Water div PlanetHeader^.Size;
  11434.                   PlanetHeader^.Size:=random(15)+5;
  11435.                   PlanetHeader^.Water:=PlanetHeader^.Water*PlanetHeader^.Size;
  11436.                   Population:=Size*400;   Biosphäre:=170;
  11437.                   Infrastruktur:=165;     Industrie:=160;
  11438.                   ProjectPtr:=ptr(PMemA[1,l]);
  11439.                   l:=l-1;
  11440.                   HomePlanetProd:=HomePlanetProd+Size;
  11441.                end;
  11442.             end;
  11443.          end;
  11444.          Save.ImperatorState[1]:=Save.ImperatorState[1]-(HomePlanetProd*3);
  11445.          if round(HomePlanetProd/15)>1 then for i:=1 to 42 do Save.TechCosts[1,i]:=round(Save.TechCosts[1,i]*(HomePlanetProd/15));
  11446.       end;
  11447.    end;
  11448.    for i:=1 to 200 do for j:=1 to SystemHeader[1].Planets do begin
  11449.       PlanetHeader:=ptr(SystemHeader[1].PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  11450.       with PlanetHeader^ do begin
  11451.          d:=1/((j*3)+1);
  11452.          sin_rot:=sin(d);  cos_rot:=cos(d);
  11453.          PosX:=PosX * cos_rot - PosY*sin_rot;
  11454.          PosY:=PosX * sin_rot + PosY*cos_rot*(1+d*d);
  11455.          if round(PosX)=round(PosY) then PosX:=round(PosY);
  11456.       end;
  11457.    end;
  11458.    SystemX[1]:=10+random(250)+random(208);
  11459.    SystemY[1]:=10+random(250)+random(240);
  11460.    for i:=2 to MAXSYSTEMS do begin
  11461.       repeat
  11462.          SystemX[i]:=10+random(250)+random(208);
  11463.          SystemY[i]:=10+random(250)+random(240);
  11464.          b:=true;
  11465.          for j:=1 to pred(i) do if SystemY[i] in [SystemY[j]-10..SystemY[j]+10] then b:=false;
  11466.       until b;
  11467.       with SystemHeader[i] do begin
  11468.          Planets:=0;
  11469.          PlanetMemA:=0;
  11470.          FirstShip:=DefaultShip;
  11471.       end;
  11472.       for j:=1 to (MAXCIVS-2) do SystemFlags[j,i]:=FLAG_UNKNOWN;
  11473.    end;
  11474.    for k:=2 to (MAXCIVS-2) do begin
  11475.       repeat
  11476.          i:=random(MAXSYSTEMS-1)+2;
  11477.       until SystemHeader[i].Planets=0;
  11478.       SystemFlags[1,i]:=GETCIVFLAG(k);
  11479.       SystemFlags[k,i]:=FLAG_KNOWN;
  11480.       CREATENEWSYSTEM(i,k);
  11481.       with SystemHeader[i] do for j:=0 to pred(Planets) do begin
  11482.          FirstShip.Owner:=GETCIVFLAG(k);
  11483.          PlanetHeader:=ptr(PlanetMemA+sizeof(r_PlanetHeader)*j);
  11484.          if j=2 then PlanetHeader^:=r_PlanetHeader(CLASS_EARTH,1,GETCIVFLAG(k),GETCIVFLAG(k),'',13,0,4000,73,170,165,160,0,0,0,DefaultShip,ptr(PMemA[k,1]));
  11485.          PlanetHeader^.PName:=PNames[k,succ(j)];
  11486.          PlanetHeader^.Water:=PlanetHeader^.Water div PlanetHeader^.Size;
  11487.          PlanetHeader^.Size:=random(15)+5;
  11488.          PlanetHeader^.Water:=PlanetHeader^.Water*PlanetHeader^.Size;
  11489.       end;
  11490.       SystemFlags[k,i]:=SystemFlags[k,i]+FLAG_KNOWN;
  11491.       SystemHeader[i].SysOwner:=GETCIVFLAG(k);
  11492.  
  11493.       if HomePlanets>1 then begin
  11494.          HomePlanetProd:=0;
  11495.          l:=Homeplanets;
  11496.          for j:=0 to pred(SystemHeader[i].Planets) do begin
  11497.             PlanetHeader:=ptr(SystemHeader[i].PlanetMemA+sizeof(r_PlanetHeader)*j);
  11498.             if PlanetHeader^.Class in [CLASS_DESERT,CLASS_HALFEARTH,CLASS_EARTH,
  11499.             CLASS_WATER,CLASS_STONES,CLASS_ICE] then begin
  11500.                if (l>0) and ((l>1) or (j>1)) then with PlanetHeader^ do begin
  11501.                   PFlags:=GETCIVFLAG(k);  Ethno:=PFlags;
  11502.                   PlanetHeader^.Water:=PlanetHeader^.Water div PlanetHeader^.Size;
  11503.                   PlanetHeader^.Size:=random(15)+5;
  11504.                   PlanetHeader^.Water:=PlanetHeader^.Water*PlanetHeader^.Size;
  11505.                   Population:=Size*400;   Biosphäre:=170;
  11506.                   Infrastruktur:=165;     Industrie:=160;
  11507.                   ProjectPtr:=ptr(PMemA[k,l]);
  11508.                   l:=l-1;
  11509.                   HomePlanetProd:=HomePlanetProd+Size;
  11510.                end;
  11511.             end;
  11512.          end;
  11513.          Save.ImperatorState[k]:=Save.ImperatorState[k]-(HomePlanetProd*3);
  11514.          if HomePlanetProd/15>1 then for i:=1 to 42 do Save.TechCosts[k,i]:=round(Save.TechCosts[k,i]*(HomePlanetProd/15));
  11515.       end;
  11516.    end;
  11517.    if HomePlanets>1 then for k:=1 to (HomePlanets+3) do for i:=1 to (MAXCIVS-2) do
  11518.     if Save.CivPlayer[i]<>0 then for j:=1 to 42 do Save.ProjectCosts[i,j]:=round(Save.ProjectCosts[i,j]*INFLATION);
  11519.    for j:=1 to MAXHOLES do with MyWormHole[j] do begin
  11520.       for i:=1 to MAXCIVS do CivKnowledge[i]:=0;
  11521.       System[1]:=random(MAXSYSTEMS+1);
  11522.       System[2]:=random(MAXSYSTEMS+1);
  11523.       if (System[1]=0) or (System[2]=0) or (System[1]=System[2]) then begin
  11524.          System[1]:=0; System[2]:=0;
  11525.       end else begin
  11526.          for i:=1 to 2 do begin
  11527.             PosX[i]:=35-random(70); if PosX[i]<4 then PosX[i]:=4; if random(2)=0 then PosX[i]:=-PosX[i];
  11528.             PosY[i]:=35-random(70); if PosY[i]<4 then PosY[i]:=4; if random(2)=0 then PosY[i]:=-PosY[i];
  11529.          end;
  11530.       end;
  11531.    end;
  11532.    INITSTARS:=true;
  11533. end;
  11534.  
  11535.  
  11536.  
  11537. procedure CREATEPATHS;
  11538.  
  11539. var btx         :^byte;
  11540. var i           :integer;
  11541. var l           :long;
  11542.  
  11543. begin
  11544.    i:=1; l:=PathMemA;
  11545.    repeat
  11546.       PathStr[i]:=ptr(l);
  11547.       repeat
  11548.          btx:=ptr(l); l:=l+1;
  11549.          if btx^=10 then btx^:=0;
  11550.       until (l>PathMeMA+PathMemL) or (btx^=0) or (i>PATHS);
  11551.       i:=i+1;
  11552.    until (i>PATHS) or (l>PathMeMA+PathMemL);
  11553. end;
  11554.  
  11555.  
  11556.  
  11557. function FIRSTMENU:byte;
  11558.  
  11559. var i           :byte;
  11560. var l,m         :long;
  11561. var s           :string;
  11562.  
  11563. begin
  11564.    SWITCHDISPLAY;
  11565.    s:='Lqqxt3Uz7D+=>.GE1IGL56789:;^ixY@XRSD^V\HYZ';
  11566.    INITMENU;
  11567.    WRITE(320,55,40,16,MyScreen[2]^,4,'IMPERIUM TERRANUM 2');
  11568.    WRITE(320,71,40,16,MyScreen[2]^,3,'- War of the Worlds -');
  11569.    WRITE(320,70,40,16,MyScreen[2]^,4,'______________________');
  11570.    WRITE(320,435,40,16,MyScreen[2]^,3,'Version 2.8');
  11571.    WRITE(320,455,40,16,MyScreen[2]^,3,'Surround-sounds, created with the WaveTracer DS®');
  11572.    WRITE(320,128,40,16,MyScreen[2]^,3,'Frei kopierbare Version');
  11573.    WRITE(320,146,40,16,MyScreen[2]^,3,'FREEWARE and OpenSource');
  11574.    WRITE(320,164,40,16,MyScreen[2]^,3,'Created by VirtualWorlds Productions:http://www.VirtualWorlds.de');
  11575.   
  11576.    MAKEBORDER(MyScreen[2]^,150,200,490,230,40,14,0);
  11577.    MAKEBORDER(MyScreen[2]^,150,240,490,270,40,14,0);
  11578.    WRITE(320,207,21,16,MyScreen[2]^,4,'Neues Spiel beginnen');
  11579.    WRITE(320,247,21,16,MyScreen[2]^,4,'Gesicherten Spielstand laden');
  11580.    ScreenToFront(MyScreen[2]);
  11581.    l:=0;
  11582.    repeat
  11583.       delay(RDELAY);
  11584.       if (LData^ and 64=0) then begin
  11585.          if IBase^.MouseX in [150..490] then begin
  11586.             if IBase^.MouseY in [200..230] then begin
  11587.                l:=1;
  11588.                CLICKRECT(MyScreen[2]^,150,200,490,230,40);
  11589.             end else if IBase^.MouseY in [240..270] then begin
  11590.                CLICKRECT(MyScreen[2]^,150,240,490,270,40);
  11591.                l:=2;
  11592.             end;
  11593.          end;
  11594.       end;
  11595.    until l<>0;
  11596.    ScreenToFront(XScreen);
  11597.    if l=1 then OPTIONMENU(1);
  11598.    if l=2 then begin
  11599.       FIRSTMENU:=1;
  11600.       if TMPTR<>0 then begin
  11601.          StopPlayer;
  11602.          UnloadModule(TMPTR);
  11603.          TMPtr:=0;
  11604.       end;
  11605.    end else FIRSTMENU:=0;
  11606.    if Save.PlayMySelf then Save.ActTech[1]:=3;
  11607. end;
  11608.  
  11609.  
  11610.  
  11611. procedure REGIERUNG;
  11612.  
  11613. var i,j,btx     :byte;
  11614. var b           :boolean;
  11615.  
  11616.  
  11617. procedure MILITÄR;
  11618.  
  11619.  
  11620. procedure DRAWDATA(BSet :byte);
  11621.  
  11622. var XState,Fight,Costs   :byte;
  11623.  
  11624. begin
  11625.    SetAPen(^MyScreen[1]^.RastPort,0);
  11626.    if (BSet in [1..8])
  11627.     or ((BSet=16) and (Save.TechCosts[ActPlayer,9]<=0))
  11628.     or ((BSet=32) and (Save.TechCosts[ActPlayer,23]<=0))
  11629.      then if (Save.Military[ActPlayer] and BSet=0) then
  11630.      Save.Military[ActPlayer]:=Save.Military[ActPlayer]+BSet
  11631.      else Save.Military[ActPlayer]:=Save.Military[ActPlayer]-BSet;
  11632.    btx:=1; XState:=0; Fight:=0; Costs:=Save.Military[ActPlayer];
  11633.    for i:=1 to 6 do begin
  11634.       if (Save.Military[ActPlayer] and btx=btx) then begin
  11635.          XState:=XState+i;
  11636.          Fight:=Fight+8;
  11637.          WRITE(74,i*30+95,12,1,MyScreen[1]^,4,'|');
  11638.       end else RectFill(^MyScreen[1]^.RastPort,74,i*30+95,90,i*30+110);
  11639.       btx:=btx*2;
  11640.    end;
  11641.    s:=' -'+intstr(XState);
  11642.    WRITE(280,310,8,32+1,MyScreen[1]^,2,s);
  11643.    s:=' +'+intstr(Fight);
  11644.    WRITE(280,335,8,32+1,MyScreen[1]^,2,s);
  11645.    s:=' +'+intstr(Costs)+'%';
  11646.    WRITE(294,360,8,32+1,MyScreen[1]^,2,s);
  11647. end;
  11648.  
  11649.  
  11650. begin
  11651.    MAKEBORDER(MyScreen[1]^,50,70,460,400,12,6,0);
  11652.    for i:=1 to 6 do MAKEBORDER(MyScreen[1]^,70,i*30+90,95,i*30+115,12,6,1);
  11653.    WRITE(255,80,ActPlayerFlag,16,MyScreen[1]^,4,'Militärische Ausbildung');
  11654.    WRITE(110,125,12,0,MyScreen[1]^,4,'IntensivTraining');
  11655.    WRITE(110,155,12,0,MyScreen[1]^,4,'ExtremTraining');
  11656.    WRITE(110,185,12,0,MyScreen[1]^,4,'Gehirnwäsche');
  11657.    WRITE(110,215,12,0,MyScreen[1]^,4,'Psychodrogen');
  11658.    if Save.TechCosts[ActPlayer,9]<=0 then s:='gentechnische Manipulation' else s:='---  (benötigt '+Technology[9]+')';
  11659.    WRITE(110,245,12,0,MyScreen[1]^,4,s);
  11660.    if Save.TechCosts[ActPlayer,23]<=0 then s:='bioelektronische Gehirnimplantate' else s:='--- (benötigt '+Technology[23]+')';
  11661.    WRITE(110,275,12,0,MyScreen[1]^,4,s);
  11662.    WRITE(70,310,ActPlayerFlag,0,MyScreen[1]^,4,'Imperatorstatus:');
  11663.    WRITE(70,335,ActPlayerFlag,0,MyScreen[1]^,4,'Kampferfahrung:');
  11664.    WRITE(70,360,ActPlayerFlag,0,MyScreen[1]^,4,'Kostenzuwachs:');
  11665.    DRAWDATA(0);
  11666.    repeat
  11667.       delay(RDELAY);
  11668.       if (LData^ and 64=0) then begin
  11669.          PLAYSOUND(1,300);
  11670.          if IBase^.MouseX in [70..440] then begin
  11671.             if IBase^.MouseY in [120..145] then DRAWDATA(1)
  11672.             else if IBase^.MouseY in [150..175] then DRAWDATA(2)
  11673.             else if IBase^.MouseY in [180..205] then DRAWDATA(4)
  11674.             else if IBase^.MouseY in [210..235] then DRAWDATA(8)
  11675.             else if IBase^.MouseY in [240..265] then DRAWDATA(16)
  11676.             else if IBase^.MouseY in [270..295] then DRAWDATA(32)
  11677.          end;
  11678.       end;
  11679.    until (RData^ and 1024=0)
  11680. end;
  11681.  
  11682.  
  11683.  
  11684. procedure FINANZEN;
  11685.  
  11686.  
  11687. procedure WRITEDATA(Mode :byte);
  11688.  
  11689. begin
  11690.    s:=intstr(Save.GSteuer[ActPlayer])+'%';
  11691.    while length(s)<4 do s:='0'+s;
  11692.    WRITE(367,147,8,33,MyScreen[1]^,2,s);
  11693.    s:=intstr(100-Save.JSteuer[ActPlayer]-Save.GSteuer[ActPlayer]-Save.SService[ActPlayer])+'%';
  11694.    while length(s)<4 do s:='0'+s;
  11695.    WRITE(367,192,8,33,MyScreen[1]^,2,s);
  11696.    s:=intstr(Save.SService[ActPlayer])+'%';
  11697.    while length(s)<4 do s:='0'+s;
  11698.    WRITE(367,237,8,33,MyScreen[1]^,2,s);
  11699.    if (Save.WorldFlag=WFLAG_JAHADR) and (Save.JSteuer[ActPlayer]+Mode>0) and
  11700.    not (Save.WarState[ActPlayer,8] in [LEVEL_UNKNOWN,LEVEL_DIED])
  11701.    then begin
  11702.       s:=intstr(Save.JSteuer[ActPlayer])+'%';
  11703.       while length(s)<4 do s:='0'+s;
  11704.       WRITE(367,327,8,33,MyScreen[1]^,2,s);
  11705.    end;
  11706. end;
  11707.  
  11708.  
  11709. begin
  11710.    MAKEBORDER(MyScreen[1]^,60,100,430,275,12,6,0);
  11711.    WRITE(256,110,ActPlayerFlag,16,MyScreen[1]^,4,'Verteilung Finanzen');
  11712.    WRITE(80,147,12,0,MyScreen[1]^,4,'ins Guthaben');
  11713.    WRITE(80,192,ActPlayerFlag,0,MyScreen[1]^,4,'Einnahmen für Projekte');
  11714.    WRITE(80,237,12,0,MyScreen[1]^,4,'für Geheimdienst');
  11715.    for i:=1 to 3 do MAKEBORDER(MyScreen[1]^,291,i*45+97,370,i*45+120,12,6,1);
  11716.    WRITE(310,170,12,0,MyScreen[1]^,2,'I J');
  11717.    WRITE(310,215,12,0,MyScreen[1]^,2,'J I');
  11718.    if (Save.WorldFlag=WFLAG_JAHADR) and (Save.JSteuer[ActPlayer]>0) and
  11719.    not (Save.WarState[ActPlayer,8] in [LEVEL_UNKNOWN,LEVEL_DIED])
  11720.    then begin
  11721.       MAKEBORDER(MyScreen[1]^,60,300,430,365,12,6,0);
  11722.       WRITE(325,305,8,0,MyScreen[1]^,2,'I');
  11723.       WRITE(80,316,FLAG_OTHER,0,MyScreen[1]^,4,'Sicherheitsabgabe');
  11724.       MAKEBORDER(MyScreen[1]^,291,322,370,345,12,6,1);
  11725.       WRITE(80,333,FLAG_OTHER,0,MyScreen[1]^,4,'an Dominion');
  11726.    end;
  11727.    WRITEDATA(0);
  11728.    repeat
  11729.       delay(RDELAY);
  11730.       if (LData^ and 64=0) then begin
  11731.          PLAYSOUND(1,300);
  11732.          if IBase^. MouseY in [165..188] then begin
  11733.             if IBase^.MouseX in [300..330] then begin
  11734.                if Save.GSteuer[ActPlayer]<100-Save.JSteuer[ActPlayer]-Save.SService[ActPlayer]
  11735.                 then Save.GSteuer[ActPlayer]:=Save.GSteuer[ActPlayer]+1;
  11736.             end else if IBase^.MouseX in [335..365] then begin
  11737.                if Save.GSteuer[ActPlayer]>0
  11738.                 then Save.GSteuer[ActPlayer]:=Save.GSteuer[ActPlayer]-1;
  11739.             end;
  11740.             WRITEDATA(0);
  11741.          end;
  11742.          if IBase^. MouseY in [210..233] then begin
  11743.             if IBase^.MouseX in [300..330] then begin
  11744.                if Save.SService[ActPlayer]<100-Save.JSteuer[ActPlayer]-Save.GSteuer[ActPlayer] then
  11745.                 Save.SService[ActPlayer]:=Save.SService[ActPlayer]+1;
  11746.             end else if IBase^.MouseX in [335..365] then begin
  11747.                if Save.SService[ActPlayer]>0 then
  11748.                 Save.SService[actPlayer]:=Save.SService[actPlayer]-1;
  11749.             end;
  11750.             WRITEDATA(0);
  11751.          end;
  11752.          if (IBase^.MouseX in [320..340]) and (IBase^.MouseY in [300..320])
  11753.          and (Save.WorldFlag=WFLAG_JAHADR) and (Save.JSteuer[ActPlayer]>0) then begin
  11754.             while Save.JSteuer[ActPlayer]>0 do begin
  11755.                Save.JSteuer[ActPlayer]:=Save.JSteuer[ActPlayer]-1;
  11756.                WRITEDATA(1);
  11757.                PLAYSOUND(1,300);
  11758.                delay(10);
  11759.             end;
  11760.             GOTOWAR(ActPlayerFlag,FLAG_OTHER);
  11761.             exit;
  11762.          end;
  11763.       end;
  11764.    until (RData^ and 1024=0);
  11765. end;
  11766.  
  11767.  
  11768.  
  11769. procedure DOSSIER(Cheat :boolean);
  11770.  
  11771. var i   :integer;
  11772.  
  11773. begin
  11774.    MAKEBORDER(MyScreen[1]^,0,50,510,255,12,6,0);
  11775.    MAKEBORDER(MyScreen[1]^,0,256,510,442,12,6,0);
  11776.    WRITE(175,60,12,32,MyScreen[1]^,3,'Status');
  11777.    WRITE(275,60,12,32,MyScreen[1]^,3,'Bevölkerung');
  11778.    WRITE(345,60,12,32,MyScreen[1]^,3,'Militär');
  11779.    WRITE(430,60,12,32,MyScreen[1]^,3,'Guthaben');
  11780.    WRITE(500,60,12,32,MyScreen[1]^,3,'Wertung');
  11781.    for i:=1 to pred(MAXCIVS) do if ((Save.WarState[i,ActPlayer]<>LEVEL_UNKNOWN)
  11782.    or (i=ActPlayer) or Cheat) and ((i<8) or
  11783.    not (Save.WorldFlag in [0,WFLAG_FIELD])) then begin
  11784.       s:=GETCIVNAME(i);
  11785.       WRITE(14,i*20+70,GETCIVFLAG(i),0,MyScreen[1]^,3,s);
  11786.       if i<8 then WRITE(i*73-35,265,GETCIVFLAG(i),16,MyScreen[1]^,3,s);
  11787.       case Save.WarState[ActPlayer,i] of
  11788.          LEVEL_ALLIANZ: s:='Allianz';
  11789.          LEVEL_WAR:     s:='Krieg';
  11790.          LEVEL_DIED:    s:='---';
  11791.          otherwise      s:='Frieden';
  11792.       end;
  11793.       if i<>ActPlayer then WRITE(175,i*20+70,GETCIVFLAG(i),32,MyScreen[1]^,3,s);
  11794.       if (i=ActPlayer) or (Save.WarState[ActPlayer,i]=LEVEL_DIED) or
  11795.       (Save.SSMoney[ActPlayer,i]>Save.WarPower[i]*39) or (Cheat) then begin
  11796.          s:=intstr(Save.Bevölkerung[i])+' Mio';
  11797.          WRITE(275,i*20+70,GETCIVFLAG(i),32,MyScreen[1]^,3,s);
  11798.          s:=intstr(Save.WarPower[i]);
  11799.          WRITE(345,i*20+70,GETCIVFLAG(i),32,MyScreen[1]^,3,s);
  11800.          s:=intstr(Save.Staatstopf[i]);
  11801.          WRITE(430,i*20+70,GETCIVFLAG(i),32,MyScreen[1]^,3,s);
  11802.          for j:=1 to 7 do if ((i in [1..7]) or not (Save.WorldFlag in [0,WFLAG_FIELD]))
  11803.          and (not (Save.WarState[i,j] in [LEVEL_DIED,LEVEL_UNKNOWN])
  11804.          or Cheat) and ((i<>j) or (GETCIVVAR(Save.WorldFlag)=i)) then begin
  11805.             case Save.WarState[i,j] of
  11806.                LEVEL_ALLIANZ: s:='Allianz';
  11807.                LEVEL_DIED:    s:='---';
  11808.                LEVEL_WAR:     s:='Krieg';
  11809.                otherwise begin
  11810.                   s:='Frieden';
  11811.                   if (Save.WorldFlag=WFLAG_JAHADR) and (i=8) and (Save.JSteuer[j]>0)
  11812.                   then s:='SCHUTZ';
  11813.                end;
  11814.             end;
  11815.             if (i=j) and (GETCIVVAR(Save.WorldFlag)=i)
  11816.             then WRITE(j*73-35,267+i*18,GETCIVFLAG(i),21,MyScreen[1]^,3,'Krieg')
  11817.             else WRITE(j*73-35,267+i*18,GETCIVFLAG(i),16,MyScreen[1]^,3,s);
  11818.          end;
  11819.       end else WRITE(210,i*20+70,GETCIVFLAG(i),0,MyScreen[1]^,3,'keine Informationen');
  11820.       s:=intstr(Save.ImperatorState[i]);
  11821.       WRITE(500,i*20+70,GETCIVFLAG(i),32,MyScreen[1]^,3,s);
  11822.    end;
  11823.    WAITLOOP(false);
  11824. end;
  11825.  
  11826.  
  11827.  
  11828. procedure PROJEKTE;
  11829.  
  11830. var i,k,CivVar          :byte;
  11831. var j                   :word;
  11832. var YPos                :array [1..7] of word;
  11833. var MyPlanetHeader      :^r_PlanetHeader;
  11834.  
  11835. begin
  11836.    MAKEBORDER(MyScreen[1]^,0,1,511,511,12,6,0);
  11837.    for i:=1 to 3 do begin
  11838.       WRITE(i*167+5,15,12,32,MyScreen[1]^,1,Project[i]);
  11839.       YPos[i]:=40;
  11840.    end;
  11841.    for i:=1 to Save.SYSTEMS do with SystemHeader[i] do if PlanetMemA>0 then begin
  11842.       for j:=1 to SystemHeader[i].Planets do begin
  11843.          MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  11844.          if MyPlanetHeader^.PFlags and FLAG_CIV_MASK<>0 then with MyPlanetHeader^ do begin
  11845.             CivVar:=GETCIVVAR(PFlags);
  11846.             if (Save.SSMoney[ActPlayer,CivVar]>Save.WarPower[CivVar]*39)
  11847.             or (CivVar=ActPlayer) then
  11848.             for k:=1 to 3 do if (ProjectPtr^[k]<>0) and (YPos[k]<500) then begin
  11849.                WRITE(k*167+5,YPos[k],GETCIVFLAG(CivVar),32,MyScreen[1]^,1,PName);
  11850.                YPos[k]:=YPos[k]+11;
  11851.             end;
  11852.          end;
  11853.       end;
  11854.    end;
  11855.    j:=0;
  11856.    for i:=1 to 3 do if YPos[i]>j then j:=YPos[i];
  11857.    j:=j+15;
  11858.    if j<500 then begin
  11859.       for i:=1 to 7 do YPos[i]:=j;
  11860.       SetAPen(^MyScreen[1]^.RastPort,12);
  11861.       Move(^MyScreen[1]^.RastPort,10,YPos[1]-10);
  11862.       Draw(^MyScreen[1]^.RastPort,500,YPos[1]-10);
  11863.       for i:=4 to 7 do begin
  11864.          WRITE((i-3)*125+5,YPos[i],12,32,MyScreen[1]^,1,Project[i]);
  11865.          YPos[i]:=YPos[i]+15;
  11866.       end;
  11867.       for i:=1 to Save.SYSTEMS do with SystemHeader[i] do if PlanetMemA>0 then begin
  11868.          for j:=1 to SystemHeader[i].Planets do begin
  11869.             MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  11870.             if MyPlanetHeader^.PFlags and FLAG_CIV_MASK<>0 then with MyPlanetHeader^ do begin
  11871.                CivVar:=GETCIVVAR(PFlags);
  11872.                if (Save.SSMoney[ActPlayer,CivVar]>Save.WarPower[CivVar]*39)
  11873.                or (CivVar=ActPlayer) then
  11874.                for k:=4 to 7 do if (ProjectPtr^[k]<>0) and (YPos[k]<500) then begin
  11875.                   WRITE((k-3)*125+5,YPos[k],GETCIVFLAG(CivVar),32,MyScreen[1]^,1,PName);
  11876.                   YPos[k]:=YPos[k]+11;
  11877.                end;
  11878.             end;
  11879.          end;
  11880.       end;
  11881.    end;
  11882.    j:=0;
  11883.    for i:=1 to 7 do if YPos[i]>j then j:=YPos[i];
  11884.    j:=j+30;
  11885.    if j<500 then begin
  11886.       for i:=4 to 7 do YPos[i]:=j;
  11887.       SetAPen(^MyScreen[1]^.RastPort,12);
  11888.       Move(^MyScreen[1]^.RastPort,10,YPos[4]-25);
  11889.       Draw(^MyScreen[1]^.RastPort,500,YPos[4]-25);
  11890.       WRITE(255,YPos[4]-15,12,16,MyScreen[1]^,1,'Projekte noch im Bau:');
  11891.       for i:=1 to Save.SYSTEMS do with SystemHeader[i] do if PlanetMemA>0 then begin
  11892.          for j:=1 to SystemHeader[i].Planets do begin
  11893.             MyPlanetHeader:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  11894.             if MyPlanetHeader^.PFlags and FLAG_CIV_MASK<>0 then with MyPlanetHeader^ do begin
  11895.                CivVar:=GETCIVVAR(PFlags);
  11896.                if (Save.SSMoney[ActPlayer,CivVar]>Save.WarPower[CivVar]*39)
  11897.                or (CivVar=ActPlayer) then
  11898.                if (ProjectID in [4..7]) and (YPos[ProjectID]<500) then begin
  11899.                   WRITE((ProjectID-3)*125+5,YPos[ProjectID],GETCIVFLAG(CivVar),32,MyScreen[1]^,1,PName);
  11900.                   YPos[ProjectID]:=YPos[ProjectID]+11;
  11901.                end;
  11902.             end;
  11903.          end;
  11904.       end;
  11905.    end;
  11906.    WAITLOOP(false);
  11907. end;
  11908.  
  11909.  
  11910.  
  11911. procedure STATISTIK;
  11912.  
  11913. type XStr9=array[1..9] of str;
  11914.  
  11915. var ActPProjects                                :^ByteArr42;
  11916. var MyPlanet                                    :^r_PlanetHeader;
  11917. var Produktivität,Kreativität,Planeten,Bio,Infra,
  11918.     Ind,Grösse,Eth,l,Buildings                  :long;
  11919. var Str9                                        :XStr9;
  11920.  
  11921. begin
  11922.    Produktivität:=0; Kreativität:=0; Planeten:=0; Bio:=0;
  11923.    Infra:=0;         Ind:=0;         Grösse:=0;   Eth:=0;
  11924.    Buildings:=0;
  11925.    for i:=1 to Save.SYSTEMS do if (SystemFlags[ActPlayer,i] and FLAG_KNOWN=FLAG_KNOWN) then
  11926.     with SystemHeader[i] do for j:=1 to Planets do begin
  11927.       MyPlanet:=ptr(PlanetMemA+pred(j)*sizeof(r_PlanetHeader));
  11928.       with MyPlanet^ do if (PFlags and FLAG_CIV_MASK=ActPlayerFlag) then begin
  11929.          ActPProjects:=ProjectPtr;
  11930.          Planeten:=Planeten+1;
  11931.          Kreativität:=Kreativität+      ActPProjects^[33]+ActPProjects^[35]+
  11932.                       ActPProjects^[36]+ActPProjects^[38]+ActPProjects^[42];
  11933.          Produktivität:=Produktivität+    ActPProjects^[31]+ActPProjects^[37]+
  11934.                         ActPProjects^[38]+ActPProjects^[41]+ActPProjects^[42];
  11935.          Buildings:=Buildings+       ActPProjects^[30]+ActPProjects^[31]+
  11936.                     ActPProjects^[35]+ActPProjects^[36]+ActPProjects^[37]+
  11937.                     ActPProjects^[38]+ActPProjects^[39]+ActPProjects^[41];
  11938.          if ActPProjects^[34]>0 then Buildings:=Buildings+1;
  11939.          if ActPProjects^[40]>0 then Buildings:=Buildings+1;
  11940.          Bio:=Bio+Biosphäre;
  11941.          Infra:=Infra+Infrastruktur;
  11942.          Ind:=Ind+Industrie;
  11943.          Grösse:=Grösse+Size;
  11944.          if (Ethno<>0) and (PFlags and FLAG_CIV_MASK<>Ethno) then Eth:=Eth+1;
  11945.       end;
  11946.    end;
  11947.    MAKEBORDER(MyScreen[1]^,10,30,500,390,12,6,0);
  11948.    Str9:=XStr9('Forschung:','Produktivität:','Biosphären:','Infrastruktur:',
  11949.                'Industrie:','Einwohner/Planet (Mio):','Planetengröße:',
  11950.                'ethnische Probleme:','Entwicklungsstufe:');
  11951.    for i:=1 to 9 do WRITE(30,30+i*20,12,0,MyScreen[1]^,4,Str9[i]);
  11952.    if Planeten>0 then begin
  11953.       s:=realstr(Kreativität/Planeten*20,2)+'%';
  11954.       WRITE(365,50,8,32,MyScreen[1]^,2,s);
  11955.       s:=realstr(Produktivität/Planeten*20,2)+'%';
  11956.       WRITE(365,70,8,32,MyScreen[1]^,2,s);
  11957.       s:=realstr(Bio/Planeten/2,2)+'%';
  11958.       WRITE(365,90,8,32,MyScreen[1]^,2,s);
  11959.       s:=realstr(Infra/Planeten/2,2)+'%';
  11960.       WRITE(365,110,8,32,MyScreen[1]^,2,s);
  11961.       s:=realstr(Ind/Planeten/2,2)+'%';
  11962.       WRITE(365,130,8,32,MyScreen[1]^,2,s);
  11963.       s:=intstr(round(Save.Bevölkerung[ActPlayer]/Planeten));
  11964.       WRITE(350,150,8,32,MyScreen[1]^,2,s);
  11965.       s:=intstr(round(Grösse/Planeten/10));
  11966.       WRITE(350,170,8,32,MyScreen[1]^,2,s);
  11967.       s:=realstr(Eth/Planeten*100,2)+'%';
  11968.       WRITE(365,190,8,32,MyScreen[1]^,2,s);
  11969.    end;
  11970.  
  11971.    WRITE(30,240,ActPlayerFlag,0,MyScreen[1]^,4,'Bevölkerung:');
  11972.    WRITE(60,260,ActPlayerFlag,0,MyScreen[1]^,4,'Zufriedenheit:');
  11973.    WRITE(60,280,ActPlayerFlag,0,MyScreen[1]^,4,'Stimmung:');
  11974.  
  11975.    if Planeten>0 then begin
  11976.       l:=round((Buildings/Planeten*10)+(Bio/Planeten/2)+(Infra/Planeten/2));
  11977.       s:=realstr(l/3.1,2)+'%';
  11978.       WRITE(385,260,8,32,MyScreen[1]^,2,s);
  11979.       case round(l/31) of
  11980.          0: s:='äußerst gefährlich'
  11981.          1: s:='sehr gefährlich'
  11982.          2: s:='gefährlich'
  11983.          3: s:='sehr schlecht'
  11984.          4: s:='schlecht'
  11985.          5: s:='mäßig'
  11986.          6: s:='durchschnittlich'
  11987.          7: s:='gut'
  11988.          8: s:='sehr gut'
  11989.          otherwise s:='hervorragend';
  11990.       end;
  11991.       WRITE(280,280,ActPlayerFlag,0,MyScreen[1]^,4,s);
  11992.  
  11993.       l:=l div 3;
  11994.       if l<50 then s:='Urwald'
  11995.       else if l in [50..55] then s:='steinzeitlich'
  11996.       else if l in [56..60] then s:='Jäger und Sammler'
  11997.       else if l in [61..65] then s:='feudalistisch'
  11998.       else if l in [66..70] then s:='frühkapitalistisch'
  11999.       else if l in [71..75] then s:='frühindustriell'
  12000.       else if l in [76..80] then s:='durchschnittlich'
  12001.       else if l in [81..85] then s:='gut'
  12002.       else if l in [86..90] then s:='sehr gut'
  12003.       else if l>90 then s:='erstklassig';
  12004.       WRITE(260,210,12,0,MyScreen[1]^,4,s);
  12005.    end;
  12006.    s:='Militärausgaben: '+intstr(Militärausgaben[ActPlayer]);
  12007.    WRITE(30,310,12,0,MyScreen[1]^,4,s);
  12008.    s:='Entwicklungszeit: '+intstr(Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]] div succ(AllCreative[ActPlayer]))+' Jahre';
  12009.    WRITE(30,330,12,0,MyScreen[1]^,4,s);
  12010.    s:='Imperatorstatus: '+intstr(Save.ImperatorState[ActPlayer])+' Punkte';
  12011.    WRITE(30,350,12,0,MyScreen[1]^,4,s);
  12012.    s:=intstr(MaquesShips)+'  '+intstr(Save.WarPower[9]);
  12013.    WRITE(13,32,12,0,MyScreen[1]^,1,s);
  12014.    WAITLOOP(false);
  12015. end;
  12016.  
  12017.  
  12018.  
  12019. procedure FORSCHUNG;
  12020.  
  12021. var l   :long;
  12022. var i   :byte;
  12023. var s   :string;
  12024.  
  12025. begin
  12026.    MAKEBORDER(MyScreen[1]^,0,0,510,330,12,6,0);
  12027.    WRITE(255,10,ActPlayerFlag,16,MyScreen[1]^,4,'Technologien');
  12028.    for i:=1 to 2 do for j:=1 to 21 do if Save.TechCosts[ActPlayer,pred(i)*21+j]<=0 then
  12029.     WRITE(pred(i)*245+10,j*14+15,12,0,MyScreen[1]^,3,Technology[pred(i)*21+j])
  12030.    else
  12031.     WRITE(pred(i)*245+10,j*14+15,29,0,MyScreen[1]^,3,Technology[pred(i)*21+j]);
  12032.  
  12033.    MAKEBORDER(MyScreen[1]^,0,331,510,400,12,6,0);
  12034.    if Save.ActTech[ActPlayer]>0 then begin
  12035.       s:=Technology[Save.ActTech[ActPlayer]]+', '+intstr(Save.TechCosts[ActPlayer,Save.ActTech[ActPlayer]] div succ(AllCreative[ActPlayer]))+' Jahre';
  12036.       WRITE(255,342,ActPlayerFlag,16,MyScreen[1]^,4,s);
  12037.       MAKEBORDER(MyScreen[1]^,20,365,492,390,6,12,0);
  12038.       l:=Save.TechCosts[ActPlayer,Save.ActTech[1]];
  12039.       if l<0 then l:=0;
  12040.       RECT(MyScreen[1]^,8,22,367,490-round(468*l/Save.TechCosts[ActPlayer,42]),388);
  12041.    end else WRITE(255,342,ActPlayerFlag,16,MyScreen[1]^,4,'keine Entwicklung');
  12042.  
  12043.    {ShipData:    MaxLoad,MaxShield,MaxMove,WeaponPower}
  12044.    MAKEBORDER(MyScreen[1]^,0,401,510,510,12,6,0);
  12045.    WRITE(10,410,12,0,MyScreen[1]^,3,'Schiffstyp');
  12046.    WRITE(110,410,12,0,MyScreen[1]^,3,'Laderaum');
  12047.    WRITE(210,410,12,0,MyScreen[1]^,3,'Bewegung');
  12048.    WRITE(310,410,12,0,MyScreen[1]^,3,'Schilde');
  12049.    WRITE(410,410,12,0,MyScreen[1]^,3,'Bewaffnung');
  12050.    l:=0;
  12051.    for i:=24 downto 8 do if (Save.TechCosts[ActPlayer,ProjectNeedsTech[i]]<=0) then begin
  12052.       if (l<4) then begin
  12053.          l:=l+1;
  12054.          WRITE(10,415+l*18,ActPlayerFlag,0,MyScreen[1]^,3,Project[i]);
  12055.          s:=intstr(ShipData[i].MaxLoad);     WRITE(150,415+l*18,ActPlayerFlag,32,MyScreen[1]^,3,s);
  12056.          s:=intstr(ShipData[i].MaxMove);     WRITE(250,415+l*18,ActPlayerFlag,32,MyScreen[1]^,3,s);
  12057.          s:=intstr(ShipData[i].MaxShield);   WRITE(350,415+l*18,ActPlayerFlag,32,MyScreen[1]^,3,s);
  12058.          s:=intstr(ShipData[i].WeaponPower); WRITE(450,415+l*18,ActPlayerFlag,32,MyScreen[1]^,3,s);
  12059.       end;
  12060.    end;
  12061.    WAITLOOP(false);
  12062. end;
  12063.  
  12064.  
  12065.  
  12066. begin
  12067.    MAKEBORDER(MyScreen[1]^,194,119,316,276,12,6,1);
  12068.    for i:=1 to 7 do DrawImage(^MyScreen[1]^.RastPort,^GadImg1,198,100+i*22);
  12069.    WRITE(255,124,0,16,MyScreen[1]^,4,'Militär');
  12070.    WRITE(255,146,0,16,MyScreen[1]^,4,'Finanzen');
  12071.    WRITE(255,168,0,16,MyScreen[1]^,4,'Dossier');
  12072.    WRITE(255,190,0,16,MyScreen[1]^,4,'Projekte');
  12073.    WRITE(255,212,0,16,MyScreen[1]^,4,'Statistik');
  12074.    WRITE(255,234,0,16,MyScreen[1]^,4,'Forschung');
  12075.    WRITE(255,256,8,16,MyScreen[1]^,4,'Zu leicht!!');
  12076.    b:=false;
  12077.    repeat
  12078.       delay(RDELAY);
  12079.       if (LData^ and 64=0) then begin
  12080.          if IBase^.MouseX in [196..314] then begin
  12081.             if IBase^.MouseY in [122..142] then begin
  12082.                KLICKGAD(198,122);   MILITÄR;     b:=true;
  12083.             end else if IBase^.MouseY in [144..164] then begin
  12084.                KLICKGAD(198,144);   FINANZEN;    b:=true;
  12085.             end else if IBase^.MouseY in [166..186] then begin
  12086.                KLICKGAD(198,166);   DOSSIER(false);     b:=true;
  12087.             end else if IBase^.MouseY in [188..208] then begin
  12088.                KLICKGAD(198,188);   PROJEKTE;    b:=true;
  12089.             end else if IBase^.MouseY in [210..230] then begin
  12090.                KLICKGAD(198,210);   STATISTIK;   b:=true;
  12091.             end else if IBase^.MouseY in [232..252] then begin
  12092.                KLICKGAD(198,232);   FORSCHUNG;   b:=true;
  12093.             end else if IBase^.MouseY in [254..274] then begin
  12094.                KLICKGAD(198,254);
  12095.                RECT(MyScreen[1]^,0,194,119,316,276);
  12096.                REFRESHDISPLAY;
  12097.                PUMPUPTHELEVEL;
  12098.                b:=true;
  12099.             end else if IBase^.MouseY=0 then begin
  12100.                if (random(20)=0) and (Save.WorldFlag in [0,WFLAG_CEBORC]) then begin
  12101.                   WAITLOOP(false);
  12102.                   REQUEST('Für die Benutzung dieser illegalen Funktion',
  12103.                           'wird eine Horde Borg (Schweden?) losgelassen!',
  12104.                   ActPlayerFlag,ActPlayerFlag);
  12105.                   REQUEST('Viel Spaß mit denen!!','-----------------',
  12106.                   ActPlayerFlag,ActPlayerFlag);
  12107.                   CEBORCATTACK(ActPlayerFlag);
  12108.                end;
  12109.                DOSSIER(true);   b:=true;
  12110.             end;
  12111.          end;
  12112.       end;
  12113.    until b or (RData^ and 1024=0);
  12114.    DRAWSTARS(MODE_REDRAW,ActPlayer);
  12115. end;
  12116.  
  12117.  
  12118.  
  12119.  
  12120.  
  12121. procedure SMALLGAMEEXIT;
  12122.  
  12123. var i           :byte;
  12124.  
  12125. begin
  12126.    DMACON_WRITE^:=$000F;
  12127.    if ImgBitMap4.MemA<>0 then FreeMem(ImgBitMap4.MemA,ImgBitMap4.MemL);
  12128.    ImgBitMap4.MemA:=0;
  12129.    if ImgBitMap7.MemA<>0 then FreeMem(ImgBitMap7.MemA,ImgBitMap7.MemL);
  12130.    ImgBitMap7.MemA:=0;
  12131.    if ImgBitMap8.MemA<>0 then FreeMem(ImgBitMap8.MemA,ImgBitMap8.MemL);
  12132.    ImgBitMap8.MemA:=0;
  12133.    for i:=1 to MODULES do if ModMemA[i]>0 then begin
  12134.       FreeMem(ModMemA[i],ModMemL[i]); ModMemA[i]:=0;
  12135.    end;
  12136.    for i:=1 to CACHES do if CacheMemA[i]>0 then begin
  12137.       FreeMem(CacheMemA[i],CacheMemL[i]); CacheMemA[i]:=0;
  12138.    end;
  12139.    for i:=0 to (MAXCIVS-2) do if LogoMemA[i]>0 then begin
  12140.       FreeMem(LogoMemA[i],LOGOSIZE);  LogoMemA[i]:=0;
  12141.    end;
  12142.    for i:=0 to (MAXCIVS-2) do if LogoSMemA[i]<>0 then begin
  12143.       FreeMem(LogoSMemA[i],LogoSMemL[i]);  LogoMemA[i]:=0;
  12144.    end;
  12145. end;
  12146.  
  12147.  
  12148.  
  12149.  
  12150. procedure GAMEEXIT;
  12151.  
  12152. var i   :integer;
  12153.  
  12154. begin
  12155.    SMALLGAMEEXIT;
  12156.    for i:=0 to IMAGES do if IMemA[i]>0 then begin
  12157.       FreeMem(IMemA[i],IMemL[i]);     IMemA[i]:=0;
  12158.    end;
  12159.    for i:=1 to SOUNDS do if SoundMemA[i]>0 then begin
  12160.       FreeMem(SoundMemA[i],SoundSize[i]*2);
  12161.       SoundMemA[i]:=0;
  12162.    end;
  12163.    if ZeroSound>0 then begin
  12164.       FreeMem(ZeroSound,8);           ZeroSound:=0;
  12165.    end;
  12166.    OpenWorkBench;
  12167.    CLOSEMYSCREENS;
  12168.    FREESYSTEMMEMORY;
  12169.    if PathMemA>0  then FreeMem(PathMemA,PathMemL);
  12170.    if XScreen<>NIL then CloseScreen(XScreen);
  12171. end;
  12172.  
  12173.  
  12174.  
  12175. procedure ENDSEQUENZ(Mode :short);
  12176.  
  12177. type SArr13=array [1..11] of str;
  12178.  
  12179. var SA13        :SArr13;
  12180. var i,j,t       :byte;
  12181. var FHandle     :BPTR;
  12182. var MPTR        :long;
  12183. var s2          :string;
  12184.  
  12185. begin
  12186.    ScreenToFront(XScreen);
  12187.    SMALLGAMEEXIT;
  12188.    while MyScreen[1]^.FirstWindow<>NIL do CloseWindow(MyScreen[1]^.FirstWindow);
  12189.    CloseScreen(MyScreen[1]);
  12190.  
  12191.    IMemL[0]:=230656;
  12192.    IMemA[0]:=AllocMem(IMemL[0],MEMF_CHIP);
  12193.    if IMemA[0]=0 then exit;
  12194.    MyScreen[1]:=OPENCINEMA(8);
  12195.    if MyScreen[1]=NIL then exit;
  12196.    if Mode in [1,-3] then s:=PathStr[5]+'MOD.HappyEnd' else s:=PathStr[5]+'MOD.DeadEnd';
  12197.    FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  12198.    if FHandle<>0 then DosClose(FHandle);
  12199.    MPTR:=LoadModule(s);
  12200.    PlayModule(MPTR);
  12201.    delay(5);
  12202.  
  12203.    t:=8;
  12204.    if Mode=-1 then begin
  12205.       if Save.WorldFlag=WFLAG_FIELD then begin
  12206.          s:=PathStr[5]+'FieldEnd.pal';
  12207.          i:=SETCOLOR(MyScreen[1]^,s);
  12208.          s:=PathStr[5]+'FieldEnd.img';
  12209.       end else begin
  12210.          s:=PathStr[5]+'ST/DeadEnd.pal';
  12211.          i:=SETCOLOR(MyScreen[1]^,s);
  12212.          s:=PathStr[5]+'ST/DeadEnd.img';
  12213.       end;
  12214.    end else if Mode=-2 then begin
  12215.       s:=PathStr[5]+'BigBang.pal';
  12216.       i:=SETCOLOR(MyScreen[1]^,s);
  12217.       s:=PathStr[5]+'BigBang.img';
  12218.    end else begin
  12219.       s:=PathStr[5]+'HappyEnd.pal';
  12220.       i:=SETCOLOR(MyScreen[1]^,s);
  12221.       s:=PathStr[5]+'HappyEnd.img';
  12222.    end;
  12223.    if not DISPLAYIMAGE(s,0,75,640,360,8,MyScreen[1]^,0) then begin end;
  12224.    SetRGB4(^MyScreen[1]^.ViewPort,255,7,7,7);
  12225.    if Mode=-1 then begin
  12226.       s:='Im Jahre '+intstr(Year)+' endete die Geschichte';
  12227.       if Save.WorldFlag=WFLAG_FIELD then begin
  12228.          SA13:=SArr13(s,'aller Zivilisationen.',
  12229.                       'Einige von ihnen waren zwar in der Lage gewesen, hoch-',
  12230.                       'entwickelte Raumschiffe zu bauen, aber sie hatten die',
  12231.                       'Technologien, die sie nutzten, nie wirklich verstanden.',
  12232.                       'Nur so war es möglich, das durch die Explosion eines',
  12233.                       'einzelnen Raumschiffes der ganze Quadrant in eine Zeit-',
  12234.                       'Anomalie geraten konnte, ohne daß irgendjemand diese',
  12235.                       'Störung hätte beseitigen können.',
  12236.                       'So wird dieser Quadrant mit all seinen Lebewesen auf',
  12237.                       'ewig in dieser Anomalie gefangen sein.');
  12238.          t:=11;
  12239.       end else begin
  12240.          s2:='der '+GETCIVADJ(ActPlayer)+'n Zivilisation.';
  12241.          SA13:=SArr13(s,s2,
  12242.                       'Sie war nicht in der Lage gewesen, sich den Heraus-',
  12243.                       'forderungen des täglichen Kampfes mit feindlichen',
  12244.                       'Zivilisationen zu stellen.',
  12245.                       'Alle von ihr besiedelten Planeten wurden besetzt.',
  12246.                       'Ihre Geschichte endete mit der Besiegung des letzten',
  12247.                       'Schiffes und der Besetzung des letzten Planeten, der noch',
  12248.                       'verzweifelt versucht hatte, sich gegen die gewaltige',
  12249.                       'feindliche Übermacht zur Wehr zu setzen.','');
  12250.          t:=10;
  12251.       end;
  12252.    end else if Mode=-2 then begin
  12253.       s:=intstr(Year)+' realisierten die '+GETCIVNAME(ActPlayer)+' das größte Projekt';
  12254.       SA13:=SArr13(s,'aller Zeiten: sie beschritten den Weg zu einer neuen,',
  12255.                    'körperlosen und perfekten Lebensform, dem Kontinuum.',
  12256.                    'Doch leider wurde vergessen, zuvor das BIG-BANG-Projekt',
  12257.                    'durchzuführen!',
  12258.                    'Und schon wenige Milliarden Jahre später begann der',
  12259.                    'Weltraum zu kollabieren: der Zeitpunkt eines neuen',
  12260.                    'Urknalls näherte sich und mit ihm das Ende jeglichen',
  12261.                    'Lebens!','','');
  12262.          t:=9;
  12263.    end else if Mode=-3 then begin
  12264.       Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-1500;
  12265.       s:='Im Jahre '+intstr(Year)+' gelingt es den '+GETCIVNAME(ActPlayer)+'n entgültig,';
  12266.       SA13:=SArr13(s,'den Widerstand aller fremden Zivilisationen zu brechen.',
  12267.                    'Es ist ihnen durch ihre aggressive Expansionspolitik',
  12268.                    'gelungen, alle anderen Zivilisationen des Quadranten zu',
  12269.                    'unterwerfen. Jetzt ist der Weg frei in eine neue Zukunft,',
  12270.                    'eine Zukunft, die mit dem Blut vieler Millionen Lebewesen',
  12271.                    'erkauft wurde. Spätere Generationen werden einmal den',
  12272.                    'Preis für die Unterwerfung dieser Zivilisationen zahlen',
  12273.                    'müssen: wenn diese sich in gewaltigen Aufständen',
  12274.                    'erheben und dieses Weltreich zerschlagen!','');
  12275.       t:=10;
  12276.    end else if Mode=1 then begin
  12277.       s:='';
  12278.       if ActPlayer<>3 then s:='n';
  12279.       s:='Im Jahre '+intstr(Year)+' gelingt es den '+GETCIVNAME(ActPlayer)+s+', das';
  12280.       SA13:=SArr13(s,'größte Projekt ihrer Geschichte durchzuführen, den',
  12281.                    'Übergang in eine neue, körperlose und perfekte',
  12282.                    'Lebensform.',
  12283.                    'Diesen Schritt konnten sie noch vor allen anderen',
  12284.                    'Zivilisationen durchführen.',
  12285.                    'Sie hat damit das Tor zu einer Lebensform durchschritten,',
  12286.                    'die frei von allen Mängeln irdischen Lebens ist: völlig',
  12287.                    'unabhängig von Raum und Zeit!','','');
  12288.       t:=9;
  12289.    end else begin
  12290.       s:='';
  12291.       if Mode<>3 then s:='n';
  12292.       s:='Im Jahre '+intstr(Year)+' gelingt es den '+GETCIVNAME(Mode)+s+', das größte';
  12293.       SA13:=SArr13(s,'Projekt ihrer Geschichte durchzuführen, den Übergang in',
  12294.                    'eine neue, körperlose und perfekte Lebensform.',
  12295.                    'Die terranische Zivilisation war leider technologisch und',
  12296.                    'wirtschaftlich nicht in der Lage gewesen, diesen Schritt',
  12297.                    'selbst zu tun.',
  12298.                    'Damit hat die Menschheit die größte Chance ihrer ganzen',
  12299.                    'Geschichte verpaßt...','','','');
  12300.    end;
  12301.    ScreenToFront(MyScreen[1]);
  12302.    delay(200);
  12303.    for i:=1 to t do begin
  12304.       WRITE(320,i*23+85,255,80,MyScreen[1]^,4,SA13[i]);
  12305.       delay(50);
  12306.    end;
  12307.    if Mode=-2 then WRITE(320,340,255,16,MyScreen[1]^,1,'(Womit bewiesen wäre, daß unser Universum geschlossen ist!)');
  12308.    WAITLOOP(false);
  12309.    if MPTR<>0 then begin
  12310.       StopPlayer;
  12311.       UnloadModule(MPTR);
  12312.    end;
  12313.    SWITCHDISPLAY;
  12314.    RECT(MyScreen[1]^,0,0,75,639,434);
  12315. end;
  12316.  
  12317.  
  12318.  
  12319.  
  12320.  
  12321.  
  12322. procedure DECODE;
  12323.  
  12324. var AddrX       :long;
  12325. var Data1,Data2 :^byte;
  12326.  
  12327. begin
  12328.    with Key do begin
  12329.       for i:=1 to 6 do begin
  12330.          AddrX:=addr(Key)+sizeof(Key);
  12331.          Data1:=ptr(AddrX); AddrX:=AddrX-1;
  12332.          Data2:=ptr(AddrX);
  12333.          repeat
  12334.             Data1:=ptr(AddrX); AddrX:=AddrX-1;
  12335.             Data2:=ptr(AddrX);
  12336.             Data1^:=Data1^-Data2^
  12337.          until AddrX<=addr(Key)+1;
  12338.  
  12339.          AddrX:=addr(Key);
  12340.          repeat
  12341.             Data1:=ptr(AddrX); AddrX:=AddrX+1;
  12342.             Data1^:=Data1^ XOR 147;
  12343.          until AddrX>=sizeof(r_Key)+addr(Key);
  12344.       end;
  12345.    end;
  12346. end;
  12347.  
  12348.  
  12349.  
  12350. procedure DISPLAYSTATE;
  12351.  
  12352. var l   :long;
  12353.  
  12354. begin
  12355.    Screen2:=0;
  12356.    SetRGB4(^MyScreen[2]^.ViewPort,0,0,0,3);
  12357.    SetRGB4(^MyScreen[2]^.ViewPort,1,12,12,15);
  12358.    SetRGB4(^MyScreen[2]^.ViewPort,2,15,0,3);
  12359.    RECT(MyScreen[2]^,0,0,0,639,511);
  12360.    WRITE(320,40,1,16,MyScreen[2]^,5,'Highscore-Trekkiestatus');
  12361.  
  12362.    WRITE(100,130,1,0,MyScreen[2]^,4,'erreichte Punktzahl:');
  12363.    s:=intstr(Save.ImperatorState[ActPlayer]);
  12364.    WRITE(540,130,2,32,MyScreen[2]^,2,s);
  12365.  
  12366.    WRITE(100,160,1,0,MyScreen[2]^,4,'Levelbonus:');
  12367.    s:=intstr(round(Save.ImperatorState[ActPlayer]*(1+Level/30))-Save.ImperatorState[ActPlayer]);
  12368.    WRITE(540,160,2,32,MyScreen[2]^,2,s);
  12369.  
  12370.    WRITE(100,190,1,0,MyScreen[2]^,4,'Spieldauer:');
  12371.    s:=intstr(-Year); if Year<0 then s:='0';
  12372.    WRITE(540,190,2,32,MyScreen[2]^,2,s);
  12373.  
  12374.    WRITE(540,210,2,32,MyScreen[2]^,2,'-------');
  12375.  
  12376.    WRITE(100,240,1,0,MyScreen[2]^,4,'Gesamtpunktzahl:');
  12377.    l:=round(Save.ImperatorState[ActPlayer]* (1+Level/30));
  12378.    if Year>0 then s:=intstr(l-Year) else s:=intstr(l);
  12379.    WRITE(540,240,2,32,MyScreen[2]^,2,s);
  12380.  
  12381.    WRITE(540,270,2,32,MyScreen[2]^,2,'-------');
  12382.    WRITE(540,275,2,32,MyScreen[2]^,2,'-------');
  12383.    ScreenToFront(MyScreen[2]);
  12384.    repeat
  12385.       delay(RDELAY);
  12386.    until (LData^ and 64=0) or (RData^ and 1024=0);
  12387.    PLAYSOUND(1,300);
  12388.    repeat
  12389.       delay(RDELAY);
  12390.    until (not (LData^ and 64=0) and not (RData^ and 1024=0)) or Bool;
  12391. end;
  12392.  
  12393.  
  12394.  
  12395. procedure MAIN;
  12396.  
  12397. var i,j         :integer;
  12398. var l           :long;
  12399. var s           :string;
  12400.  
  12401. begin
  12402.    INITVARS;
  12403.    OpenLib(DiskFontBase,'diskfont.library',0);
  12404.    CustomTA[1]:=TextAttr('StarFont.font',11,0,0);
  12405.    CustomTA[2]:=TextAttr(CustomTA[1].ta_Name,14,0,0);
  12406.    CustomTA[3]:=TextAttr(CustomTA[1].ta_Name,15,0,0);
  12407.    CustomTA[4]:=TextAttr(CustomTA[1].ta_Name,17,0,0);
  12408.    CustomTA[5]:=TextAttr(CustomTA[1].ta_Name,28,2,0);
  12409.    for i:=1 to FONTS do begin
  12410.       CustomFont[i]:=OpenDiskFont(^CustomTA[i]);
  12411.       if CustomFont[i]=NIL then begin
  12412.          DisplayBeep(NIL);
  12413.          error('StarFont 14, 15, 17 und 28 wird benötigt!');
  12414.       end;
  12415.    end;
  12416.    CloseLib(DiskFontBase);
  12417.    IBase:=IntBase;
  12418.    LData:=ptr($BFE001);
  12419.    LData^:=LData^ or 2;
  12420.    RData:=ptr($DFF016);
  12421.  
  12422.    FHandle:=DosOpen('Paths.txt',MODE_OLDFILE);
  12423.    if FHandle=0 then exit;
  12424.    PathMemL:=DosSeek(FHandle,0,OFFSET_END);
  12425.    PathMemL:=DosSeek(FHandle,0,OFFSET_BEGINNING);
  12426.    PathMemA:=AllocMem(PathMemL,MEMF_CLEAR);
  12427.    if PathMemA=0 then begin
  12428.       DosClose(FHandle);
  12429.       writeln('Kann File Paths.txt nicht finden');
  12430.       exit;
  12431.    end;
  12432.    l:=DosRead(FHandle,ptr(PathMemA),PathMemL);
  12433.    DosClose(FHandle);
  12434.    CREATEPATHS;
  12435.  
  12436.    HelpID:=$A0000;
  12437.    INITSTDTAGS;
  12438.    NeuScreen:=NewScreen(0,0,116,201,7,0,0,HIRES+LACE,CUSTOMSCREEN+SCREENQUIET,NIL,'',NIL,NIL);
  12439.    XScreen:=OpenScreenTagList(^NeuScreen,^Tags);
  12440.    if XScreen=NIL then begin
  12441.       HelpID:=$20000;
  12442.       INITSTDTAGS;
  12443.       XScreen:=OpenScreenTagList(^NeuScreen,^Tags);
  12444.    end;
  12445.    if XScreen=NIL then begin
  12446.       writeln('Kann Screen nicht öffnen');
  12447.       GAMEEXIT;
  12448.       exit;
  12449.    end;
  12450.    for i:=1 to 127 do SetRGB4(^XScreen^.ViewPort,i,0,0,0);
  12451.    INITCHANNELS;
  12452.    MAININTRO;
  12453.    if not OPENMAINSCREENS then begin
  12454.       GAMEEXIT;
  12455.       writeln('Kann Screens nicht öffnen');
  12456.       exit;
  12457.    end;
  12458.    WBench:=CloseWorkBench;
  12459.  
  12460.    s:='Nicht genug Speicher';
  12461.    with ImgBitMap4 do begin
  12462.       MemL:=30720;   {640 x 96 x 4}
  12463.       MemA:=AllocMem(MemL,MEMF_CHIP+MEMF_CLEAR);
  12464.       if MemA=0 then begin
  12465.          GAMEEXIT;
  12466.          writeln(s);
  12467.          exit;
  12468.       end;
  12469.       ImgBitMap4:=ITBitMap(80,96,1,4,0,ptr(MemA),      ptr(MemA+7680), ptr(MemA+15360),
  12470.                                        ptr(MemA+23040),NIL,NIL,NIL,NIL,MemA,MemL);
  12471.    end;
  12472.    with ImgBitMap7 do begin
  12473.       MemL:=28672;   {512 x 64 x 7}
  12474.       MemA:=AllocMem(MemL,MEMF_CHIP+MEMF_CLEAR);
  12475.       if MemA=0 then begin
  12476.          GAMEEXIT;
  12477.          writeln(s);
  12478.          exit;
  12479.       end;
  12480.       ImgBitMap7:=ITBitMap(64,64,1,7,0,ptr(MemA),      ptr(MemA+4096), ptr(MemA+8192),
  12481.                                        ptr(MemA+12288),ptr(MemA+16384),ptr(MemA+20480),
  12482.                                        ptr(MemA+24576),NIL,MemA,MemL);
  12483.    end;
  12484.    with ImgBitMap8 do begin
  12485.       MemL:=122880;  {640 x 192 x 8}
  12486.       MemA:=AllocMem(MemL,MEMF_CHIP+MEMF_CLEAR);
  12487.       if MemA=0 then begin
  12488.          GAMEEXIT;
  12489.          writeln(s);
  12490.          exit;
  12491.       end;
  12492.       ImgBitMap8:=ITBitMap(80,192,1,8,0,ptr(MemA),     ptr(MemA+15360),ptr(MemA+30720),
  12493.                                        ptr(MemA+46080),ptr(MemA+61440),ptr(MemA+76800),
  12494.                                        ptr(MemA+92190),ptr(MemA+107520),MemA,MemL);
  12495.    end;
  12496.    IMemL[0]:=287000;
  12497.    IMemA[0]:=AllocMem(IMemL[0],MEMF_CHIP);
  12498.    s:='Nicht genug Speicher';
  12499.    if IMemA[0]=0 then begin
  12500.       GAMEEXIT;
  12501.       writeln(s);
  12502.       exit;
  12503.    end;
  12504.    ZeroSound:=AllocMem(8,MEMF_CHIP+MEMF_CLEAR);
  12505.    if ZeroSound=0 then begin
  12506.       GAMEEXIT;
  12507.       writeln(s);
  12508.       exit;
  12509.    end;
  12510.    INITCHANNELS;
  12511.    INITSOUNDS;
  12512.    i:=0;
  12513.    if not WBench then begin
  12514.       WRITE(320,100,1,16,MyScreen[1]^,4,'Workbench-Screen konnte nicht geschlossen werden!');
  12515.       SetRGB4(^MyScreen[1]^.ViewPort,1,15,15,15);
  12516.       WRITE(320,130,1,16,MyScreen[1]^,4,'Maustaste zum Fortsetzen...');
  12517.       ScreenToFront(MyScreen[1]);
  12518.       WAITLOOP(false);
  12519.       RECT(MyScreen[1]^,0,0,0,639,511);
  12520.    end;
  12521.    SWITCHDISPLAY;
  12522.    if not INITDESK(1) then begin
  12523.       GAMEEXIT;
  12524.       writeln('Intuition-Error');
  12525.       exit;
  12526.    end;
  12527.    if not INITSTARS then begin
  12528.       GAMEEXIT;
  12529.       writeln(s);
  12530.       exit;
  12531.    end;
  12532.    DRAWSTARS(MODE_REDRAW,ActPlayer);
  12533.    ScreenToFront(MyScreen[1]);
  12534.    if b=1 then Bool:=DISKMENU(2) else STARTROTATEPLANETS(0);
  12535.    repeat
  12536.       delay(RDELAY);
  12537.       CLOCK;
  12538.       ScreenToFront(MyScreen[1]);
  12539.       RawCode:=GETRAWCODE;
  12540.       if Multiplayer then begin
  12541.          ShipData[8].MaxMove:=3;   ShipData[9].MaxMove:=3;
  12542.          ShipData[10].MaxMove:=3;
  12543.       end;
  12544.  
  12545.       if (Save.PlayMySelf) and (RawCode=69) then Save.PlayMySelf:=false;
  12546.       if (Save.PlayMySelf) or (Save.CivPlayer[ActPlayer]=0) or not Informed
  12547.       or (not Multiplayer and not Informed and (Year mod 10<>0)) then STARTROTATEPLANETS(0) else begin
  12548.          if (LData^ and 64=0) or (RData^ and 1024=0) then delay(3);
  12549.          if ((LData^ and 64=0) and (IBase^.MouseX in [518..634]) and (IBase^.MouseY in [472..492]))
  12550.           or ((LData^ and 64=0) and (RData^ and 1024=0)) or (RawCode in [64,67,68]) then begin
  12551.             KLICKGAD(518,472);
  12552.             STARTROTATEPLANETS(0);
  12553.          end;
  12554.          if (LData^ and 64=0) and (Save.CivPlayer[ActPlayer]<>0) then begin
  12555.  
  12556.             if (IBase^.MouseX in [0..512]) and (IBase^.MouseY in [0..512]) then begin
  12557.                PLAYSOUND(1,300);
  12558.                if SystemFlags[ActPlayer,LastSystem] and FLAG_KNOWN=FLAG_KNOWN then HANDLESYSTEM(LastSystem,NIL)
  12559.             end else if IBase^.MouseX in [518..634] then begin
  12560.                if IBase^.MouseY in [444..464] then begin
  12561.                   KLICKGAD(518,444);
  12562.                   if not DISKMENU(0) then begin
  12563.                      GAMEEXIT;
  12564.                      exit;
  12565.                   end;
  12566.                end else if IBase^.MouseY in [416..436] then begin
  12567.                   KLICKGAD(518,416);
  12568.                   REGIERUNG
  12569.                end;
  12570.             end;
  12571.          end else WRITEGALAXYDATA(0,0);
  12572.       end;
  12573.       Bool:=false;
  12574.       if Save.WorldFlag=WFLAG_FIELD then begin
  12575.          if Save.Systems<=1 then Bool:=true
  12576.       end else begin
  12577.          l:=0;
  12578.          for i:=1 to MAXCIVS do if (Save.CivPlayer[i]<>0) and (i<>ActPlayer) then l:=l+Save.Bevölkerung[i];
  12579.          if (Save.Bevölkerung[1]+Save.Bevölkerung[2]+Save.Bevölkerung[3]+
  12580.              Save.Bevölkerung[4]+Save.Bevölkerung[5]+Save.Bevölkerung[6]+
  12581.              Save.Bevölkerung[7]+Save.Bevölkerung[8]-Save.Bevölkerung[ActPlayer]<=20)
  12582.          and (l=0) then begin
  12583.             Bool:=true;
  12584.             if MultiPlayer then begin
  12585.                ENDSEQUENZ(-3);
  12586.                GAMEEXIT;
  12587.                exit;
  12588.             end;
  12589.          end;
  12590.          if not Multiplayer then begin
  12591.             if Save.Bevölkerung[1]=0 then begin
  12592.                ENDSEQUENZ(-1);
  12593.                GAMEEXIT;
  12594.                exit;
  12595.             end;
  12596.             if (Save.ProjectCosts[1,7]<=0)
  12597.             or (Save.ProjectCosts[2,7]<=0) or (Save.ProjectCosts[3,7]<=0)
  12598.             or (Save.ProjectCosts[4,7]<=0) or (Save.ProjectCosts[5,7]<=0)
  12599.             or (Save.ProjectCosts[6,7]<=0) or (Save.ProjectCosts[7,7]<=0)
  12600.             then Bool:=true;
  12601.          end else begin
  12602.             if (Save.ProjectCosts[ActPlayer,7]<=0) and (Save.WarState[ActPlayer,ActPlayer]<>LEVEL_DIED) then begin
  12603.                Bool:=true;
  12604.                for i:=1 to (MAXCIVS-2) do
  12605.                 if (Save.CivPlayer[i]<>0) and (Save.Bevölkerung[i]>10)
  12606.                 and (i<>ActPlayer) then Bool:=false;
  12607.                if Save.CivPlayer[ActPlayer]<>0 then begin
  12608.                   s:=PathStr[5]+'MOD.HappyEnd';
  12609.                   FHandle:=OPENSMOOTH(s,MODE_OLDFILE);
  12610.                   if FHandle<>0 then DosClose(FHandle);
  12611.                   TMPTR:=LoadModule(s);
  12612.                   PlayModule(TMPTR);
  12613.                   MAKEBORDER(MyScreen[1]^,40,100,470,190,12,6,0);
  12614.                   WRITE(256,113,ActPlayerFlag,16,MyScreen[1]^,4,'Ihre Zivilisation hat das Endziel erreicht:');
  12615.                   WRITE(256,137,ActPlayerFlag,16,MyScreen[1]^,4,'Sie haben den Schritt hin zum Kontinuum, einer');
  12616.                   WRITE(256,161,ActPlayerFlag,16,MyScreen[1]^,4,'neuen und überlegenen Lebensform, geschafft.');
  12617.                   WAITLOOP(Save.PlayMySelf);
  12618.                   RECT(MyScreen[1]^,0,40,100,470,190);
  12619.                   REFRESHDISPLAY;
  12620.                   REMOVEPLAYER(ActPlayer);
  12621.                   DISPLAYSTATE;
  12622.                   PLAYERHIGHSCORE(ActPlayer);
  12623.                   for i:=1 to pred(MAXCIVS) do begin
  12624.                      Save.WarState[ActPlayer,i]:=LEVEL_DIED;
  12625.                      Save.WarState[i,ActPlayer]:=LEVEL_DIED;
  12626.                   end;
  12627.                   if TMPTR<>0 then begin
  12628.                      StopPlayer;
  12629.                      UnloadModule(TMPTR);
  12630.                   end;
  12631.                   for i:=1 to MAXCIVS do Save.ImperatorState[i]:=Save.ImperatorState[i]-500;
  12632.                   if not Save.WorldFlag in [WFLAG_DCON,WFLAG_CEBORC,WFLAG_JAHADR] then Save.ImperatorState[8]:=1000;
  12633.                   if Bool then begin
  12634.                      GAMEEXIT;
  12635.                      exit;
  12636.                   end;
  12637.                end else begin
  12638.                   Bool:=false;
  12639.                   for i:=1 to MAXCIVS do if Save.ProjectCosts[i,5]<=0 then Bool:=true;
  12640.                   if not Bool then ENDSEQUENZ(-2) else begin
  12641.                      ENDSEQUENZ(1);
  12642.                      PLAYERHIGHSCORE(ActPlayer);
  12643.                   end;
  12644.                   GAMEEXIT;
  12645.                   exit;
  12646.                end;
  12647.             end;
  12648.          end;
  12649.       end;
  12650.       CLEARINTUITION;
  12651.    until Bool;
  12652.  
  12653.    Screen2:=0;
  12654.    if (Save.WorldFlag=WFLAG_FIELD) and (Save.Systems<=1) then begin
  12655.       ENDSEQUENZ(-1);
  12656.       GAMEEXIT;
  12657.       exit;
  12658.    end else if Bool then begin
  12659.       if not Multiplayer then begin
  12660.          for i:=1 to 8 do if Save.ProjectCosts[i,7]<=0 then begin
  12661.             j:=i;
  12662.             if i=8 then while Save.ImperatorState[8]>2400 do Save.ImperatorState[8]:=Save.ImperatorState[8]-random(250);
  12663.             if (i=1) and (Save.ProjectCosts[1,5]>0) then begin
  12664.                ENDSEQUENZ(-2);
  12665.                GAMEEXIT;
  12666.                exit;
  12667.             end;
  12668.             ENDSEQUENZ(j);
  12669.             DISPLAYSTATE;
  12670.             if i<8 then begin
  12671.                Save.ImperatorState[i]:=round(Save.ImperatorState[i]* (1+Level/30));
  12672.                if Year>0 then Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-Year;
  12673.             end;
  12674.          end;
  12675.          if Save.Bevölkerung[2]+Save.Bevölkerung[3]+Save.Bevölkerung[4]+
  12676.             Save.Bevölkerung[5]+Save.Bevölkerung[6]+Save.Bevölkerung[7]+
  12677.             Save.Bevölkerung[8]<=20 then begin
  12678.             ENDSEQUENZ(-3);
  12679.             DISPLAYSTATE;
  12680.             Save.ImperatorState[ActPlayer]:=round(Save.ImperatorState[ActPlayer]* (1+Level/30));
  12681.             if Year>0 then Save.ImperatorState[ActPlayer]:=Save.ImperatorState[ActPlayer]-Year;
  12682.             j:=1;
  12683.          end;
  12684.          PLAYSOUND(1,300);
  12685.          PLAYERHIGHSCORE(j);
  12686.       end;
  12687.    end;
  12688.    GAMEEXIT;
  12689. end;
  12690.  
  12691.  
  12692.  
  12693. begin
  12694.    randomize;
  12695.    OpenLib(IntBase,'intuition.library',39);
  12696.    OpenLib(GfxBase,'graphics.library',39);
  12697.    OpenLib(DosBase,'dos.library',39);
  12698.    OpenLib(MedBase,'medplayer.library',2);
  12699.    OpenLib(MTBase,'mathtrans.library',37);
  12700.    OpenLib(MDBBase,'mathieeedoubbas.library',37);
  12701.    Process_Ptr:=p_Process(FindTask(NIL));
  12702.    OldWindow_Ptr:=Process_Ptr^.pr_WindowPtr;
  12703.    Process_Ptr^.pr_WindowPtr:=ptr(-1);
  12704.    Warnung[1]:=0;
  12705.    repeat
  12706.       Year:=GetPlayer(PLAYER_NO_MIDI);
  12707.       Warnung[1]:=Warnung[1]+1;
  12708.    until (Year<>0) or (Warnung[1]>10);
  12709.    if Year=0 then writeln('Audio-Alloc/Player failed!') else begin
  12710.       if AvailMem(MEMF_FAST)=0 then writeln('Nicht genug Speicher vorhanden! FAST-RAM wird benötigt!')
  12711.       else begin
  12712.          MAIN;
  12713.          FreePlayer;
  12714.       end;
  12715.    end;
  12716.    Process_Ptr^.pr_WindowPtr:=OldWindow_Ptr;
  12717.    CloseLib(MDBBase);
  12718.    CloseLib(MTBase);
  12719.    CloseLib(MedBase);
  12720.    CloseLib(DosBase);
  12721.    CloseLib(GfxBase);
  12722.    CloseLib(IntBase);
  12723. end. { 12470 }
  12724.